Skip to main content

Produce simplified likelihoods of different formats

Project description

simplify

CI status Documentation Status codecov PyPI version python version Code style: black

A package that creates simplified likelihoods from full likelihoods. Currently, only one form of simplified likelihoods is implemented, but the idea is to implement additional versions of the simplified likelihoods, such that varying degrees of simplification can be supported.

Installation

Follow good practice and start by creating a virtual environment

python3 -m venv simplify

and then activating it

source simplify/bin/activate

Default install

Install the package with pip

python3 -m pip install simplify-hep[contrib]

Development install

If you want to contribute to simplify, install the development version of the package. Fork the repository, clone the fork, and then install

python3 -m pip install --ignore-installed -U -e .[complete]

Next, setup the git pre-commit hook for Black

pre-commit install

You can run all the tests with

python3 -m pytest

How to run

CLI

Run with e.g.

simplify convert < fullLH.json > simplifiedLH.json

or e.g.

curl http://foo/likelihood.json | simplify convert

where fullLH.json is the full likelihood you want to convert into a simplified likelihood. Simplify is able to read/write from/to stdin/stdout.

In python script

You can also use simplify in a python script, e.g. to create some validation and cross-check plots and tables.

import pyhf
import json

import simplify

pyhf.set_backend(pyhf.tensorlib, "minuit")
spec = json.load(open("likelihood.json", "r"))

ws = pyhf.Workspace(spec) # ws from full LH

# get model and data for each ws we just created
model = ws.model(modifier_settings = {"normsys": {"interpcode": "code4"},"histosys": {"interpcode": "code4p"},})
data = ws.data(model)

# run fit
fit_result = simplify.fitter.fit(ws)

plt = simplify.plot.pulls(
    fit_result,
    "plots/"
)

plt = simplify.plot.correlation_matrix(
    fit_result,
    "plots/",
    pruning_threshold=0.1
)

tables = simplify.plot.yieldsTable(
    ws,
    "plots/",
    fit_result,
)

Dependencies

Naturally relies heavily on pyhf. Part of the code for plotting and validating results is inspired by Alexander Held's cabinetry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplify-hep-0.1.3.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

simplify_hep-0.1.3-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file simplify-hep-0.1.3.tar.gz.

File metadata

  • Download URL: simplify-hep-0.1.3.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for simplify-hep-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5e0293fb9a68943aedd887b84806a11c2b3029f83af5d3a5d996365cfe676c02
MD5 458c596686280d6314b4c9865fd44736
BLAKE2b-256 915ae16465ad6f313e347749c2cf2868784befe222883dc8baa15a02c0c052e1

See more details on using hashes here.

File details

Details for the file simplify_hep-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: simplify_hep-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for simplify_hep-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 695e5803b0748d0858d151f10140fc3caf135708ddd85df1788f6bd359b38a5c
MD5 9363efccf7aa690672bf38817e489387
BLAKE2b-256 4711fb23f955c48a0917d0bbbfcafa57f9c0e089dd8e67c8150d614e5ad08bb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page