- Notifications
You must be signed in to change notification settings - Fork173
sbi is a Python package for simulation-based inference, designed to meet the needs of both researchers and practitioners. Whether you need fine-grained control or an easy-to-use interface, sbi has you covered.
License
sbi-dev/sbi
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Getting Started |Documentation |Discord Server
sbi
is a Python package for simulation-based inference, designed to meet the needs ofboth researchers and practitioners. Whether you need fine-grained control or aneasy-to-use interface,sbi
has you covered.
Withsbi
, you can perform parameter inference using Bayesian inference: Given asimulator that models a real-world process, SBI estimates the full posteriordistribution over the simulator’s parameters based on observed data. This distributionindicates the most likely parameter values while additionally quantifying uncertaintyand revealing potential interactions between parameters.
sbi
offers a blend of flexibility and ease of use:
- Low-Level Interfaces: For those who require maximum control over the inferenceprocess,
sbi
provides low-level interfaces that allow you to fine-tune many aspectsof your workflow. - High-Level Interfaces: If you prefer simplicity and efficiency,
sbi
also offershigh-level interfaces that enable quick and easy implementation of complex inferencetasks.
In addition,sbi
supports a wide range of state-of-the-art inference algorithms (seebelow for a list of implemented methods):
- Amortized Methods: These methods enable the reuse of posterior estimators acrossmultiple observations without the need to retrain.
- Sequential Methods: These methods focus on individual observations, optimizing thenumber of simulations required.
Beyond inference,sbi
also provides:
- Validation Tools: Built-in methods to validate and verify the accuracy of yourinferred posteriors.
- Plotting and Analysis Tools: Comprehensive functions for visualizing and analyzingresults, helping you interpret the posterior distributions with ease.
Getting started withsbi
is straightforward, requiring only a few lines of code:
fromsbi.inferenceimportNPE# Given: parameters theta and corresponding simulations xinference=NPE(prior=prior)inference.append_simulations(theta,x).train()posterior=inference.build_posterior()
sbi
requires Python 3.10 or higher. While a GPU isn't necessary, it can improveperformance in some cases. We recommend using a virtual environment withconda
for an easy setup.
Ifconda
is installed on the system, an environment for installingsbi
can be created as follows:
conda create -n sbi_env python=3.10&& conda activate sbi_env
To installsbi
from PyPI run
python -m pip install sbi
To install and addsbi
to a project withpixi
, from the project directory run
pixi add sbi
and to install into a particular conda environment withconda
, in the activated environment run
conda install --channel conda-forge sbi
Open a Python prompt and run
fromsbi.examples.minimalimportsimpleposterior=simple()print(posterior)
If you're new tosbi
, we recommend starting with ourGettingStarted tutorial.
You can also access and run these tutorials directly in your browser by openingCodespace. To do so, click the green“Code” button on the GitHub repository and select “Open with Codespaces.” This providesa fully functional environment where you can exploresbi
through Jupyter notebooks.
The following inference algorithms are currently available. You can find instructions onhow to run each of these methodshere.
(S)NPE_A
(including amortized single-roundNPE
) from Papamakarios G and Murray IFastε-free Inference of Simulation Models with Bayesian Conditional DensityEstimation(NeurIPS 2016).(S)NPE_C
orAPT
from Greenberg D, Nonnenmacher M, and Macke JAutomatic PosteriorTransformation for likelihood-free inference (ICML2019).TSNPE
from Deistler M, Goncalves P, and Macke JTruncated proposals for scalableand hassle-free simulation-based inference(NeurIPS 2022).FMPE
from Wildberger, J., Dax, M., Buchholz, S., Green, S., Macke, J. H., & Schölkopf, B.Flow matching for scalable simulation-basedinference.(NeurIPS 2023).NPSE
fromGeffner, T., Papamakarios, G., & Mnih, A.Compositional score modeling forsimulation-based inference.(ICML 2023)
(S)NLE
or justSNL
from Papamakarios G, Sterrat DC and Murray ISequential NeuralLikelihood (AISTATS 2019).
(S)NRE_A
orAALR
from Hermans J, Begy V, and Louppe G.Likelihood-free Inference withAmortized Approximate Likelihood Ratios (ICML2020).(S)NRE_B
orSRE
from Durkan C, Murray I, and Papamakarios G.On Contrastive Learning forLikelihood-free Inference (ICML 2020).(S)NRE_C
orNRE-C
from Miller BK, Weniger C, Forré P.Contrastive Neural RatioEstimation (NeurIPS 2022).BNRE
fromDelaunoy A, Hermans J, Rozet F, Wehenkel A, and Louppe G.Towards ReliableSimulation-Based Inference with Balanced Neural RatioEstimation (NeurIPS 2022).
SNVI
from Glöckler M, Deistler M, Macke J,Variational methods for simulation-basedinference (ICLR 2022).
MNLE
fromBoelts J, Lueckmann JM, Gao R, Macke J,Flexible and efficient simulation-basedinference for models of decision-making(eLife 2022).
We welcome any feedback on howsbi
is working for your inference problems (seeDiscussions) and are happy to receive bugreports, pull requests, and other feedback (seecontribute). We wish to maintain a positivecommunity; please read ourCode of Conduct.
sbi
is the successor (using PyTorch) of thedelfi
package. It started as a fork of Conor M.Durkan'slfi
.sbi
runs as a community project. See alsocredits.
sbi
has been supported by the German Federal Ministry of Education and Research (BMBF)through project ADIMEM (FKZ 01IS18052 A-D), project SiMaLeSAM (FKZ 01IS21055A) and theTübingen AI Center (FKZ 01IS18039A). Since 2024,sbi
is supported by the appliedAIInstitute for Europe, and by NumFOCUS.
Apache License Version 2.0 (Apache-2.0)
If you usesbi
consider citing thesbi softwarepaper, in addition to the original researcharticles describing the specific sbi-algorithm(s) you are using.
@article{tejero-cantero2020sbi, doi = {10.21105/joss.02505}, url = {https://doi.org/10.21105/joss.02505}, year = {2020}, publisher = {The Open Journal}, volume = {5}, number = {52}, pages = {2505}, author = {Alvaro Tejero-Cantero and Jan Boelts and Michael Deistler and Jan-Matthis Lueckmann and Conor Durkan and Pedro J. Gonçalves and David S. Greenberg and Jakob H. Macke}, title = {sbi: A toolkit for simulation-based inference}, journal = {Journal of Open Source Software}}
The above citation refers to the original version of thesbi
project and has apersistent DOI. Additionally, new releases ofsbi
are citable viaZenodo, where we create a new DOI for everyrelease.
About
sbi is a Python package for simulation-based inference, designed to meet the needs of both researchers and practitioners. Whether you need fine-grained control or an easy-to-use interface, sbi has you covered.