Skip to main content

Yet Another Bayesian Framework

Project description

https://img.shields.io/pypi/v/yabf.svg https://codecov.io/gh/steven-murray/yabf/branch/main/graph/badge.svg?token=fuxNCeAtof Documentation Status pre-commit.ci status

Yet Another Bayesian Framework

Features

Why another Bayesian Framework? There are a relative host of Bayesian codes in Python, including major players such as PyMC3, emcee and stan, as well as a seemingly never-ending set of scientific-field-specific codes (eg. cosmology has CosmoMC, CosmoHammer, MontePython, cobaya…).

yabf was written because the author found that all the frameowrks they tried were either too lean or too involved. yabf tries to find the happy medium. It won’t be the right tool for everyone, but it might be the right tool for you.

yabf is designed to support “black box” likelihoods, by which we mean those that don’t necessarily have analytic derivatives. This separates it from codes such as PyMC3 and stan, and limits its use to samplers that do not require that information. This is more often the case in scientific applications, where likelihoods can in principle depend on some enormous black-box simulation code. Thus, in this regard it is more like emcee or polychord.

On the other hand, yabf is not another MCMC sampler. Apart from the limitations concerning likelihood derivatives, it is sampler-agnostic. It is rather a specification of a format, and an implementation of that specification. That is, it specifies that likelihoods should have certain properties (like parameters), and gives tools that enable that. Or as another example, it specifies that samplers should contain certain attributes pre- and post-sampling. In this regard, yabf is more like PyMC3 or stan, and unlike emcee or polychord.

yabf is perhaps most similar to codes such as CosmoHammer or cobaya, which provide an interface for creating (cosmological) likelihoods which can then be sampled by somie specified sampler. However, yabf is different in that it is intended to be field-agnostic, and entirely general. In addition, I found that these codes didn’t quite satisfy my criteria for ease-of-use and extensibility.

I hope that yabf provides these. Here are a few of its features:

  • Deisgn is both DRY/modular and easy-to-use: while components of the model can be separately defined (to make it DRY), they don’t need to be combined into a rigid structure in order to perform most calculations. This makes it easy to evaluate partial models for debugging.

  • Extremely extensible: write your own class that subclasses from the in-built Component or Likelihood classes, and it is immediately useable.

  • Parameters are attached to to the model, for encapsulation, but they can be specified at run-time externally for modularity.

  • Models are heirarchical, in the sense that parameters may be specified at any of three levels, and they are propagated through the model heirarchy (note that this doesn’t refer to heirarchical parameters, i.e. parameters that depend on other parameters).

  • Parameters can be set as fixed or constrained at run-time.

  • Models are well-specified, in the sense that they can be entirely specified by a YAML file (and/or written to YAML file), for reproducibility.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Many of the ideas in this code are adaptations of other MCMC codes, especially CosmoHammer and cobaya.

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

yabf-2.1.0.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

yabf-2.1.0-py2.py3-none-any.whl (34.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file yabf-2.1.0.tar.gz.

File metadata

  • Download URL: yabf-2.1.0.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for yabf-2.1.0.tar.gz
Algorithm Hash digest
SHA256 93fb13fd9fc59434de4bf0a647a22cd63e10c4d38b9d74d7b8676733e7cf7bb8
MD5 b47ba8a3dfaf760d761ac3b4dc937b43
BLAKE2b-256 80fefc048927ffa63f5677c18b6479c497d0efad690f75a500a6e51562aa44e7

See more details on using hashes here.

Provenance

File details

Details for the file yabf-2.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: yabf-2.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for yabf-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 65decf18659a34a0409f1fa95ff7c8e829766015b0fc214eabbf0b8dfa3e8af9
MD5 1786f5147a81d584d2a5755e1c8cb4bb
BLAKE2b-256 b6e0508f54912de4e93f3a2e4d79f81a3e6a8bab930c78981270d8de6c23a07a

See more details on using hashes here.

Provenance

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