sbi


Namesbi JSON
Version 0.22.0 PyPI version JSON
download
home_pagehttps://github.com/sbi-dev/sbi
SummarySimulation-based inference.
upload_time2023-12-04 11:12:10
maintainer
docs_urlNone
authorÁlvaro Tejero-Cantero, Jakob H. Macke, Jan-Matthis Lückmann, Conor M. Durkan, Michael Deistler, Jan Bölts
requires_python>=3.6.0
licenseAGPLv3
keywords bayesian parameter inference system_identification simulator pytorch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
[![PyPI version](https://badge.fury.io/py/sbi.svg)](https://badge.fury.io/py/sbi)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbi-dev/sbi/blob/master/CONTRIBUTING.md)
[![Tests](https://github.com/sbi-dev/sbi/workflows/Tests/badge.svg?branch=main)](https://github.com/sbi-dev/sbi/actions)
[![codecov](https://codecov.io/gh/sbi-dev/sbi/branch/main/graph/badge.svg)](https://codecov.io/gh/sbi-dev/sbi)
[![GitHub license](https://img.shields.io/github/license/sbi-dev/sbi)](https://github.com/sbi-dev/sbi/blob/master/LICENSE.txt)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02505/status.svg)](https://doi.org/10.21105/joss.02505)

## sbi: simulation-based inference

[Getting Started](https://sbi-dev.github.io/sbi/tutorial/00_getting_started/) | [Documentation](https://sbi-dev.github.io/sbi/)

`sbi` is a PyTorch package for simulation-based inference. Simulation-based inference is the process of finding parameters of a simulator from observations.

`sbi` takes a Bayesian approach and returns a full posterior distribution over the parameters of the simulator, conditional on the observations.
The package implements a variety of inference algorithms, including _amortized_ and _sequential_ methods.
Amortized methods return a posterior that can be applied to many different observations without retraining; sequential methods focus the inference on one particular observation to be more simulation-efficient.
See below for an overview of implemented methods.

`sbi` offers a simple interface for one-line posterior inference:

```python
from sbi.inference import infer
# import your simulator, define your prior over the parameters
parameter_posterior = infer(simulator, prior, method='SNPE', num_simulations=100)
```

## Installation

`sbi` requires Python 3.6 or higher. We recommend to use a [`conda`](https://docs.conda.io/en/latest/miniconda.html) virtual
environment ([Miniconda installation instructions](https://docs.conda.io/en/latest/miniconda.html])). If `conda` is installed on the system, an environment for
installing `sbi` can be created as follows:

```commandline
# Create an environment for sbi (indicate Python 3.6 or higher); activate it
$ conda create -n sbi_env python=3.7 && conda activate sbi_env
```

Independent of whether you are using `conda` or not, `sbi` can be installed using `pip`:

```commandline
pip install sbi
```

To test the installation, drop into a python prompt and run

```python
from sbi.examples.minimal import simple
posterior = simple()
print(posterior)
```

## Inference Algorithms

The following algorithms are currently available. You can find a tutorial on how to run each of these methods [here](https://sbi-dev.github.io/sbi/tutorial/16_implemented_methods/).

### Neural Posterior Estimation: amortized (NPE) and sequential (SNPE)

* [`SNPE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snpe.snpe_a.SNPE_A) (including amortized single-round `NPE`) from Papamakarios G and Murray I [_Fast ε-free Inference of Simulation Models with Bayesian Conditional Density Estimation_](https://proceedings.neurips.cc/paper/2016/hash/6aca97005c68f1206823815f66102863-Abstract.html) (NeurIPS 2016).
  
* [`SNPE_C`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snpe.snpe_c.SNPE_C) or `APT` from Greenberg D, Nonnenmacher M, and Macke J [_Automatic
  Posterior Transformation for likelihood-free
  inference_](https://arxiv.org/abs/1905.07488) (ICML 2019).

* `TSNPE` from Deistler M, Goncalves P, and Macke J [_Truncated proposals for scalable and hassle-free simulation-based inference_](https://arxiv.org/abs/2210.04815) (NeurIPS 2022).

### Neural Likelihood Estimation: amortized (NLE) and sequential (SNLE)

* [`SNLE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snle.snle_a.SNLE_A) or just `SNL` from Papamakarios G, Sterrat DC and Murray I [_Sequential
  Neural Likelihood_](https://arxiv.org/abs/1805.07226) (AISTATS 2019).

### Neural Ratio Estimation: amortized (NRE) and sequential (SNRE)

* [`(S)NRE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_a.SNRE_A) or `AALR` from Hermans J, Begy V, and Louppe G. [_Likelihood-free Inference with Amortized Approximate Likelihood Ratios_](https://arxiv.org/abs/1903.04057) (ICML 2020).

* [`(S)NRE_B`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_b.SNRE_B) or `SRE` from Durkan C, Murray I, and Papamakarios G. [_On Contrastive Learning for Likelihood-free Inference_](https://arxiv.org/abs/2002.03712) (ICML 2020).

* [`BNRE`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.bnre.BNRE) from Delaunoy A, Hermans J, Rozet F, Wehenkel A, and Louppe G. [_Towards Reliable Simulation-Based Inference with Balanced Neural Ratio Estimation_](https://arxiv.org/abs/2208.13624) (NeurIPS 2022).

* [`(S)NRE_C`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_c.SNRE_C) or `NRE-C` from Miller BK, Weniger C, Forré P. [_Contrastive Neural Ratio Estimation_](https://arxiv.org/abs/2210.06170) (NeurIPS 2022).

### Neural Variational Inference, amortized (NVI) and sequential (SNVI)

* [`SNVI`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.posteriors.vi_posterior) from Glöckler M, Deistler M, Macke J, [_Variational methods for simulation-based inference_](https://openreview.net/forum?id=kZ0UYdhqkNY) (ICLR 2022).

### Mixed Neural Likelihood Estimation (MNLE)

* [`MNLE`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snle.mnle.MNLE) from Boelts J, Lueckmann JM, Gao R, Macke J, [_Flexible and efficient simulation-based inference for models of decision-making_](https://elifesciences.org/articles/77220) (eLife 2022).

## Feedback and Contributions

We welcome any feedback on how `sbi` is working for your inference problems (see [Discussions](https://github.com/sbi-dev/sbi/discussions)) and are happy to receive bug reports, pull requests and other feedback (see
[contribute](http://sbi-dev.github.io/sbi/contribute/)).
We wish to maintain a positive community, please read our [Code of Conduct](CODE_OF_CONDUCT.md).

## Acknowledgements

`sbi` is the successor (using PyTorch) of the
[`delfi`](https://github.com/mackelab/delfi) package. It was started as a fork of Conor
M. Durkan's `lfi`. `sbi` runs as a community project; development is coordinated at the
[mackelab](https://www.mackelab.org/). See also [credits](https://github.com/sbi-dev/sbi/blob/master/docs/docs/credits.md).

## Support

`sbi` has been supported by the German Federal Ministry of Education and Research (BMBF) through the project ADIMEM, FKZ 01IS18052 A-D). [ADIMEM](https://fit.uni-tuebingen.de/Project/Details?id=9199) is a collaborative project between the groups of Jakob Macke (Uni Tübingen), Philipp Berens (Uni Tübingen), Philipp Hennig (Uni Tübingen) and Marcel Oberlaender (caesar Bonn) which aims to develop inference methods for mechanistic models.

## License

[Affero General Public License v3 (AGPLv3)](https://www.gnu.org/licenses/)

## Citation

If you use `sbi` consider citing the [sbi software paper](https://doi.org/10.21105/joss.02505), in addition to the original research articles describing the specific sbi-algorithm(s) you are using. 

```latex
@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 the `sbi` project and has a persistent DOI.
Additionally, new releases of `sbi` are citable via [Zenodo](https://zenodo.org/record/3993098), where we create a new DOI for every release.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sbi-dev/sbi",
    "name": "sbi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.0",
    "maintainer_email": "",
    "keywords": "bayesian parameter inference system_identification simulator PyTorch",
    "author": "\u00c1lvaro Tejero-Cantero, Jakob H. Macke, Jan-Matthis L\u00fcckmann, Conor M. Durkan, Michael Deistler, Jan B\u00f6lts",
    "author_email": "simulation.based.inference@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/46/ad/d6494f2d3c38d9f5834027fe7f002930188776b7ac9abd14e5417e326dcd/sbi-0.22.0.tar.gz",
    "platform": null,
    "description": "\n[![PyPI version](https://badge.fury.io/py/sbi.svg)](https://badge.fury.io/py/sbi)\n[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sbi-dev/sbi/blob/master/CONTRIBUTING.md)\n[![Tests](https://github.com/sbi-dev/sbi/workflows/Tests/badge.svg?branch=main)](https://github.com/sbi-dev/sbi/actions)\n[![codecov](https://codecov.io/gh/sbi-dev/sbi/branch/main/graph/badge.svg)](https://codecov.io/gh/sbi-dev/sbi)\n[![GitHub license](https://img.shields.io/github/license/sbi-dev/sbi)](https://github.com/sbi-dev/sbi/blob/master/LICENSE.txt)\n[![DOI](https://joss.theoj.org/papers/10.21105/joss.02505/status.svg)](https://doi.org/10.21105/joss.02505)\n\n## sbi: simulation-based inference\n\n[Getting Started](https://sbi-dev.github.io/sbi/tutorial/00_getting_started/) | [Documentation](https://sbi-dev.github.io/sbi/)\n\n`sbi` is a PyTorch package for simulation-based inference. Simulation-based inference is the process of finding parameters of a simulator from observations.\n\n`sbi` takes a Bayesian approach and returns a full posterior distribution over the parameters of the simulator, conditional on the observations.\nThe package implements a variety of inference algorithms, including _amortized_ and _sequential_ methods.\nAmortized methods return a posterior that can be applied to many different observations without retraining; sequential methods focus the inference on one particular observation to be more simulation-efficient.\nSee below for an overview of implemented methods.\n\n`sbi` offers a simple interface for one-line posterior inference:\n\n```python\nfrom sbi.inference import infer\n# import your simulator, define your prior over the parameters\nparameter_posterior = infer(simulator, prior, method='SNPE', num_simulations=100)\n```\n\n## Installation\n\n`sbi` requires Python 3.6 or higher. We recommend to use a [`conda`](https://docs.conda.io/en/latest/miniconda.html) virtual\nenvironment ([Miniconda installation instructions](https://docs.conda.io/en/latest/miniconda.html])). If `conda` is installed on the system, an environment for\ninstalling `sbi` can be created as follows:\n\n```commandline\n# Create an environment for sbi (indicate Python 3.6 or higher); activate it\n$ conda create -n sbi_env python=3.7 && conda activate sbi_env\n```\n\nIndependent of whether you are using `conda` or not, `sbi` can be installed using `pip`:\n\n```commandline\npip install sbi\n```\n\nTo test the installation, drop into a python prompt and run\n\n```python\nfrom sbi.examples.minimal import simple\nposterior = simple()\nprint(posterior)\n```\n\n## Inference Algorithms\n\nThe following algorithms are currently available. You can find a tutorial on how to run each of these methods [here](https://sbi-dev.github.io/sbi/tutorial/16_implemented_methods/).\n\n### Neural Posterior Estimation: amortized (NPE) and sequential (SNPE)\n\n* [`SNPE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snpe.snpe_a.SNPE_A) (including amortized single-round `NPE`) from Papamakarios G and Murray I [_Fast \u03b5-free Inference of Simulation Models with Bayesian Conditional Density Estimation_](https://proceedings.neurips.cc/paper/2016/hash/6aca97005c68f1206823815f66102863-Abstract.html) (NeurIPS 2016).\n  \n* [`SNPE_C`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snpe.snpe_c.SNPE_C) or `APT` from Greenberg D, Nonnenmacher M, and Macke J [_Automatic\n  Posterior Transformation for likelihood-free\n  inference_](https://arxiv.org/abs/1905.07488) (ICML 2019).\n\n* `TSNPE` from Deistler M, Goncalves P, and Macke J [_Truncated proposals for scalable and hassle-free simulation-based inference_](https://arxiv.org/abs/2210.04815) (NeurIPS 2022).\n\n### Neural Likelihood Estimation: amortized (NLE) and sequential (SNLE)\n\n* [`SNLE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snle.snle_a.SNLE_A) or just `SNL` from Papamakarios G, Sterrat DC and Murray I [_Sequential\n  Neural Likelihood_](https://arxiv.org/abs/1805.07226) (AISTATS 2019).\n\n### Neural Ratio Estimation: amortized (NRE) and sequential (SNRE)\n\n* [`(S)NRE_A`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_a.SNRE_A) or `AALR` from Hermans J, Begy V, and Louppe G. [_Likelihood-free Inference with Amortized Approximate Likelihood Ratios_](https://arxiv.org/abs/1903.04057) (ICML 2020).\n\n* [`(S)NRE_B`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_b.SNRE_B) or `SRE` from Durkan C, Murray I, and Papamakarios G. [_On Contrastive Learning for Likelihood-free Inference_](https://arxiv.org/abs/2002.03712) (ICML 2020).\n\n* [`BNRE`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.bnre.BNRE) from Delaunoy A, Hermans J, Rozet F, Wehenkel A, and Louppe G. [_Towards Reliable Simulation-Based Inference with Balanced Neural Ratio Estimation_](https://arxiv.org/abs/2208.13624) (NeurIPS 2022).\n\n* [`(S)NRE_C`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snre.snre_c.SNRE_C) or `NRE-C` from Miller BK, Weniger C, Forr\u00e9 P. [_Contrastive Neural Ratio Estimation_](https://arxiv.org/abs/2210.06170) (NeurIPS 2022).\n\n### Neural Variational Inference, amortized (NVI) and sequential (SNVI)\n\n* [`SNVI`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.posteriors.vi_posterior) from Gl\u00f6ckler M, Deistler M, Macke J, [_Variational methods for simulation-based inference_](https://openreview.net/forum?id=kZ0UYdhqkNY) (ICLR 2022).\n\n### Mixed Neural Likelihood Estimation (MNLE)\n\n* [`MNLE`](https://sbi-dev.github.io/sbi/reference/#sbi.inference.snle.mnle.MNLE) from Boelts J, Lueckmann JM, Gao R, Macke J, [_Flexible and efficient simulation-based inference for models of decision-making_](https://elifesciences.org/articles/77220) (eLife 2022).\n\n## Feedback and Contributions\n\nWe welcome any feedback on how `sbi` is working for your inference problems (see [Discussions](https://github.com/sbi-dev/sbi/discussions)) and are happy to receive bug reports, pull requests and other feedback (see\n[contribute](http://sbi-dev.github.io/sbi/contribute/)).\nWe wish to maintain a positive community, please read our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n## Acknowledgements\n\n`sbi` is the successor (using PyTorch) of the\n[`delfi`](https://github.com/mackelab/delfi) package. It was started as a fork of Conor\nM. Durkan's `lfi`. `sbi` runs as a community project; development is coordinated at the\n[mackelab](https://www.mackelab.org/). See also [credits](https://github.com/sbi-dev/sbi/blob/master/docs/docs/credits.md).\n\n## Support\n\n`sbi` has been supported by the German Federal Ministry of Education and Research (BMBF) through the project ADIMEM, FKZ 01IS18052 A-D). [ADIMEM](https://fit.uni-tuebingen.de/Project/Details?id=9199) is a collaborative project between the groups of Jakob Macke (Uni T\u00fcbingen), Philipp Berens (Uni T\u00fcbingen), Philipp Hennig (Uni T\u00fcbingen) and Marcel Oberlaender (caesar Bonn) which aims to develop inference methods for mechanistic models.\n\n## License\n\n[Affero General Public License v3 (AGPLv3)](https://www.gnu.org/licenses/)\n\n## Citation\n\nIf you use `sbi` consider citing the [sbi software paper](https://doi.org/10.21105/joss.02505), in addition to the original research articles describing the specific sbi-algorithm(s) you are using. \n\n```latex\n@article{tejero-cantero2020sbi,\n  doi = {10.21105/joss.02505},\n  url = {https://doi.org/10.21105/joss.02505},\n  year = {2020},\n  publisher = {The Open Journal},\n  volume = {5},\n  number = {52},\n  pages = {2505},\n  author = {Alvaro Tejero-Cantero and Jan Boelts and Michael Deistler and Jan-Matthis Lueckmann and Conor Durkan and Pedro J. Gon\u00e7alves and David S. Greenberg and Jakob H. Macke},\n  title = {sbi: A toolkit for simulation-based inference},\n  journal = {Journal of Open Source Software}\n}\n```\n\nThe above citation refers to the original version of the `sbi` project and has a persistent DOI.\nAdditionally, new releases of `sbi` are citable via [Zenodo](https://zenodo.org/record/3993098), where we create a new DOI for every release.\n",
    "bugtrack_url": null,
    "license": "AGPLv3",
    "summary": "Simulation-based inference.",
    "version": "0.22.0",
    "project_urls": {
        "Homepage": "https://github.com/sbi-dev/sbi"
    },
    "split_keywords": [
        "bayesian",
        "parameter",
        "inference",
        "system_identification",
        "simulator",
        "pytorch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21e5e43c1b47be6ec16cf0fd43c6819ec3e7e52dfbfe0561f8b9a88b3f120f0d",
                "md5": "01da769270ef4d79363ef8575729348a",
                "sha256": "26dd81d3e1220c4ca16a33fc0779e18e35c296f97e7fae588712f17a412c058e"
            },
            "downloads": -1,
            "filename": "sbi-0.22.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "01da769270ef4d79363ef8575729348a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6.0",
            "size": 272251,
            "upload_time": "2023-12-04T11:12:08",
            "upload_time_iso_8601": "2023-12-04T11:12:08.235794Z",
            "url": "https://files.pythonhosted.org/packages/21/e5/e43c1b47be6ec16cf0fd43c6819ec3e7e52dfbfe0561f8b9a88b3f120f0d/sbi-0.22.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46add6494f2d3c38d9f5834027fe7f002930188776b7ac9abd14e5417e326dcd",
                "md5": "89625ebcf087814a26a4fe903f4b7091",
                "sha256": "e632994c0bcfbc63c110d6eb04c6e1bdf6ae4ca42211d67ab4946d9b394dc360"
            },
            "downloads": -1,
            "filename": "sbi-0.22.0.tar.gz",
            "has_sig": false,
            "md5_digest": "89625ebcf087814a26a4fe903f4b7091",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.0",
            "size": 417406,
            "upload_time": "2023-12-04T11:12:10",
            "upload_time_iso_8601": "2023-12-04T11:12:10.981945Z",
            "url": "https://files.pythonhosted.org/packages/46/ad/d6494f2d3c38d9f5834027fe7f002930188776b7ac9abd14e5417e326dcd/sbi-0.22.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-04 11:12:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sbi-dev",
    "github_project": "sbi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sbi"
}
        
Elapsed time: 0.17114s