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 use the Discussions page or contact us via 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.

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.1.tar.gz (234.2 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.1-py3-none-any.whl (218.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gpry-4.0.1.tar.gz
  • Upload date:
  • Size: 234.2 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.1.tar.gz
Algorithm Hash digest
SHA256 07da793fd12f287a1a0f0b84bdd85760819b88517e440262b47c56fb84b0a8af
MD5 38a0c694538caef9d44c98eb0a5fd4f9
BLAKE2b-256 c725afb626793e16055d8ca760d44b3d0fbb69e6ec64e5793532b654924e38be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpry-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 218.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ef19511f5668746d19b46c570986648bcd31c549769ff25a90189777ef92539
MD5 4d6f977e78ca6b47b24214466fa5e981
BLAKE2b-256 f6cdf22f4b87e71f25195d868baf0961e4c4870ece42f3946b889db193bbcff1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 files

4.0

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