Skip to main content

LF2I: Likelihood-Free Frequentist Inference

PyPI GitHub

Getting Started

What is LFI?

lf2i is a Python package for likelihood-free inference; that is, inference on the parameters $\boldsymbol{\theta}$ of a statistical model $F_{\boldsymbol{\theta}}$ in a setting where the likelihood $\mathcal{L}(\boldsymbol{\theta}; \mathcal{D}):=p(\mathcal{D}|\boldsymbol{\theta})$ cannot be evaluated but is implicitly encoded by a high-fidelity simulator for $F_{\boldsymbol{\theta}}$. In other words, one can simulate data in batches of size $n$, $\mathcal{D}=(X_1, \dots, X_n)$, for any given $\boldsymbol{\theta}$ in the parameter space.

What does LF2I do?

lf2i constructs confidence regions for internal parameters with correct coverage across the whole parameter space, that is, sets $\mathcal{R}(\mathcal{D})$ satisfying $\mathbb{P}({\boldsymbol{\theta}} \in \mathcal{R}(\mathcal{D})) = 1 - \alpha\text{ } \text{ }\forall\theta\in\Theta$, where $(1 − \alpha) \in (0, 1)$ is a prespecified confidence level.
Coverage is guaranteed regardless of

  1. the prior distribution over the parameters of interest;
  2. the true value of the parameters of interest: the coverage guarantee holds point-wise over the parameter space (i.e., not only on average); and
  3. the size of the observed sample: the coverage guarantee holds even for finite sample sizes, including for the case of one observation, i.e. $n=1$.

Structure of LF2I

lf2i is based on the equivalence of confidence sets and hypothesis tests. It leverages supervised machine learning methods to efficiently execute the Neyman construction of confidence sets. The framework has three separate modules for estimating

  1. test statistics (such as ACORE, BFF, Waldo, etc...);
  2. critical values for a level $\alpha$ test; and
  3. empirical coverage

across the entire parameter space. See the figure below for a schematic diagram.

drawing

While 1. and 2. are used to construct the confidence sets, 3. is an independent diagnostic tool that can be used to check whether a given parameter region (such as, lf2i confidence sets, posterior credible regions, prediction sets, etc …) has the right conditional coverage. Because lf2i is modular, users can construct valid confidence sets using any test statistic of their choice.

Usage

lf2i offers a simple interface that allows you to get started quickly. The entry point is the LF2I class in the lf2i.inference module, which contains classes to wrap the different functionalities. The method inference merges steps 1. and 2. to return confidence sets with correct coverage. The method diagnostics performs step 3. as an independent check of empirical coverage of the constructed parameter regions.

Check the website for the full documentation, complete of tutorials on the Waldo test statistics. Tutorials on likelihood-based test statistics like ACORE and BFF are coming soon!

Install

The package is under active development, and is available on PyPI at this link. It can be installed using pip:

pip install lf2i

The diagnostics module leverages smoothing splines implemented in R, which is assumed to be installed along with the mgcv package.

Feedback and Contributions

We strongly encourage users to leave feedback and report bugs either by using the Issues tab, or by contacting us directly. The current maintainer can be reached here.

If you want to contribute, feel free to open an issue and/or a pull request.

References

LF2I is based on the following research articles:
- Confidence sets and hypothesis testing in a likelihood-free inference setting (ICML 2020)
- Likelihood-Free Frequentist Inference: Bridging Classical Statistics and Machine Learning for Reliable Simulator-Based Inference (2021)
- Simulation-Based Inference with Waldo: Confidence Regions by Leveraging Prediction Algorithms and Posterior Estimators for Inverse Problems (AISTATS 2023)

Metadata

Release files for lf2i 0.3.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 lf2i 0.3.1
File Size Uploaded
lf2i-0.3.1.tar.gz 43.3 kB Details

Built distribution (wheel)

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

Total release size: 98.4 kB

Release files / lf2i-0.3.1.tar.gz

Download URL lf2i-0.3.1.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
704e61f72c21f787613db65171c3a2606f14c91b2204f96fd7c5e409c66f5bc5
BLAKE2b-256 checksum
How to use checksums
e0c5cb6409b349cd2b43fb1e9f13c0a2f125a6e6b9ea122c6072368c5a479a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release files / lf2i-0.3.1-py3-none-any.whl

Download URL lf2i-0.3.1-py3-none-any.whl
Size 55.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3215c56d9f115c69191a8da97ef4ad63869b42237251fa9eac561d186c381f8
BLAKE2b-256 checksum
How to use checksums
a3a937e8b708a24acd9be1daba85b26ede85d6991525c5aa26122a3db5de5bef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.2.1

1 release file

0.1.1

1 release file

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