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 the user can chose the one he likes the most (or needs the most).

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 caan run all the tests with

python3 -m pytest

How to run

CLI

Run with

simplify convert -i <fullLH.json> -o <simplifiedLH.json>

where fullLH.json is the full likelihood you want to convert into a simplified likelihood.

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 simplify.

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.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

simplify_hep-0.1.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplify-hep-0.1.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6

File hashes

Hashes for simplify-hep-0.1.1.tar.gz
Algorithm Hash digest
SHA256 938e7a055cf65575fd03f879a84a0d5a4ae99375ee4f2deaa0153bde2474ad60
MD5 1906312d4cea2b46303e0f280f4d0201
BLAKE2b-256 c8d95d0c68b8de875b26e37bc2fdcf1c98883a617be275ce501852476347b471

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simplify_hep-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6

File hashes

Hashes for simplify_hep-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11edc4f99b32c75ff337ecae818c7dbdd94f8c75d616faf5ce46ca0f7e60b48c
MD5 06783c5d48fd30e2d936613f26696624
BLAKE2b-256 b61a4f71a35e9c80d442f41adf2969a94113f23a7ba594e5750d5ab8289e7970

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