Skip to main content

GPry: Bayesian inference of expensive likelihoods with Gaussian Processes

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

Metadata

Release files for gpry 4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpry 4.1
File Size Uploaded
gpry-4.1.tar.gz 243.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpry 4.1
File Interpreter ABI Platform
gpry-4.1-py3-none-any.whl Python 3 none any Details

Total release size: 460.2 kB

Release files / gpry-4.1.tar.gz

Download URL gpry-4.1.tar.gz
Size 243.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f12663bb08271eab02aa4fb7d4b8792fc5f199d21067411ce424f938d0e28f5a
BLAKE2b-256 checksum
How to use checksums
5a0d8698f81d8c5ec8094c3ed0b249041fc0afafdb87430312e74e8de0bb0d8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / gpry-4.1-py3-none-any.whl

Download URL gpry-4.1-py3-none-any.whl
Size 216.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
248650b39aa896d9251da706f5e6785f69f4cd977479906467d55789b88b9067
BLAKE2b-256 checksum
How to use checksums
581b67ad976d6094a51dec25ef961b31df7f163a54faa685a6b41e41c9bddb4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.1 This release

2 release files

4.0.1

2 release files

4.0

2 release files

3.0.0

2 release files

2.0.1

2 release files

1.1.0

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page