Skip to main content
Author:

Jonas El Gammal, Jesus Torrado, Nils Schoeneberg and Christian Fidler

Source:

Source code on GitHub

Documentation:

Documentation on Read the Docs

License:

LGPL + bug reporting asap + arXiv’ing of publications using it (see LICENSE for exceptions). The documentation is licensed under the GFDL.

Support:

For questions drop me an email. For issues/bugs please use GitHub’s Issues.

Installation:

pip install gpry (for MPI and nested samplers, see here)

GPry is a drop-in alternative to traditional Monte Carlo samplers (such as MCMC or Nested Sampling), for likelihood-based inference. It is aimed at speeding up posterior exploration and inference of marginal quantities from computationally expensive likelihoods, reducing the cost of inference by a factor of 100 or more. GPry can also provide an estimation of the model evidence.

GPry can be installed with pip (python -m pip install gpry), and needs only a callable log-likelihood and some bounds:

def log_likelihood(x, y):
    return [...]

bounds = [[..., ...], [..., ...]]

from gpry import Runner

runner = Runner(log_likelihood, bounds, checkpoint="output/", load_checkpoint="overwrite")
runner.run()
https://github.com/jonaselgammal/GPry/blob/main/doc/source/images/adv_animation.gif?raw=true

Animated progress for the advanced example

An interface to the Cobaya sampler is available, for richer model especification, and direct access to some physical likelihood pipelines.

GPry was developed as part of J. El Gammal’s M.Sc. and Ph.D. theses projects.

# TODO: link to some personal whebpage/github profile?

How it works

GPry uses a Gaussian Process (GP) to create an interpolating model of the log-posterior density function, using as few evaluations as possible. It achieves that using active learning: starting from a minimal set of training samples, the next ones are chosen so that they maximise the information gained on the posterior shape. For more details, see section How GPry works of the documentation, and check out the GPry papers (see below).

GPry introduces some innovations with respect to previous similar approaches:

  • It imposes weakly-informative priors on the target function, based on a comparison with an n-dimensional Gaussian, and uses that information e.g. for convergence metrics, balancing exploration vs. exploitation, etc.

  • It introduces a parallelizable batch acquisition algorithm (NORA) which increases robustness, reduces overhead and enables the evaluation of the likelihood/posterior in parallel using multiple cores.

  • Complementing the GP model, it implements an SVM classifier that learns the shape of uninteresting regions, where proposals are discarded, wherever the value of the likelihood is very-low (for increased efficiency) or undefined (for increased robustness).

At the moment, GPry utilizes a modification of the CPU-based scikit-learn GP implementation.

What kinds of likelihoods/posteriors should work with GPry?

  • Non-stochastic log-probability density functions, smooth up to a small amount of (deterministic) numerical noise (less than 0.1 in log posterior).

  • Log-likelihoods with large evaluation times, so that the GPry overhead is subdominant with respect to posterior evaluation. How slow depends on the number of dimensions and expected shape of the posterior distribution but as a rule of thumb, if an MCMC takes longer to converge than you’re willing to wait, you should give it a shot.

  • The parameter space needs to be low-dimensional (less than 20 as a rule of thumb). In higher dimensions you might still gain considerable improvements in speed if your likelihood is sufficiently slow but the computational overhead of the algorithm increases considerably.

What may not work so well:

  • Highly multimodal posteriors, especially if the separation between modes is large.

  • Highly non-Gaussian posteriors, that would not be well modelled by orthogonal constant correlation lengths.

GPry is under active development, in order to mitigate some of those issues, so look out for new versions!

It does not work!

Please check out the Strategy and Troubleshooting page, or get in touch for issues or more general discussions.

What to cite

If you use GPry, please cite the following papers:

Some papers using GPry

Download files

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

Source Distribution

gpry-4.0.tar.gz (228.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpry-4.0-py3-none-any.whl (211.8 kB view details)

Uploaded Python 3

File details

Details for the file gpry-4.0.tar.gz.

File metadata

  • Download URL: gpry-4.0.tar.gz
  • Upload date:
  • Size: 228.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gpry-4.0.tar.gz
Algorithm Hash digest
SHA256 49c58ea4f2bf4e07d0e251fcca78cb88a8e698a4d33c900186e388c5b551d96a
MD5 ea78d4e9ef7103f3b8299e3e355e4cf5
BLAKE2b-256 064dc04590756fb4a63156ba3612d6db0fc09249858287629d377185636a5606

See more details on using hashes here.

File details

Details for the file gpry-4.0-py3-none-any.whl.

File metadata

  • Download URL: gpry-4.0-py3-none-any.whl
  • Upload date:
  • Size: 211.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gpry-4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e1ac4d22fd30eda672f4e5f0a478593a5331d9ce5fb388e43eb1704a32f2beb
MD5 100bf1964c10d0a4cea12cb3ae351c7c
BLAKE2b-256 5221a2e9aa21b784f528c0c760becf0b3385213b783f311fa14457a24f0a6a56

See more details on using hashes here.

Release history Release notifications | RSS feed

4.0.1

2 files

This release

4.0 This release

2 files

3.0.0

2 files

2.0.1

2 files

1.1.0

1 file

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page