EMD falsification library
The EMD (empirical model discrepancy) criterion is used to compare models based on how well each describes the data. It is described in this publication; it’s main features are:
- Symmetric: All models are treated the same. (There is no preferred null model.) A corollary is that the test works for any number of parameters.
- Specific: Models are compared for particular parameter sets. In particular, the different models may all be the same equations but with different parameters.
- Dimension agnostic: Models are compared based on their quantile function, which is always 1d. So the method scales well to high-dimensional problems.
Problem requirements
The main requirement to be able to compute the EMD criterion are:
- Observation data.
- At least two models to compare.
- The ability to use the models to generate synthetic samples.
The models can take any form; they can even be blackbox deep neural networks.
Installation
pip install emd-falsify
Usage
The short form for comparing two models is
from emd_falsify import Bemd, make_empirical_risk
# Load data into `data`
# Define `modelA`, `modelB`
# Define `lossA`, `lossB` : functions
# Define `Lsynth` : int
# Define `c` : float
synth_ppfA = make_empirical_risk(lossA(modelA.generate(Lsynth)))
synth_ppfB = make_empirical_risk(lossB(modelB.generate(Lsynth)))
mixed_ppfA = make_empirical_risk(lossA(data))
mixed_ppfB = make_empirical_risk(lossB(data))
Bemd(mixed_ppfA, mixed_ppfB, synth_ppfA, synth_ppfB, c=c)
We also expose additional functions like the lower level draw_R_samples.
Using them is a bit more verbose, but especially for cases with multiple models to compare,
they may be more convenient.
Note that comparisons depend on choosing an appropriate value for c; a systematic way to do this is via a calibration experiment, as described in our publication.
This package provides emd_falsify.tasks.Calibrate to help run calibration experiments.
Complete usage examples
The documentation contains a simple example. Moreover, all the [code for the paper’s figures] is available, in the form of Jupyter notebooks. These are heavily commented with extra additional usage hints; they are highly recommended reading.
Debugging
If computations are taking inordinately long, set the debug level to DEBUG:
logging.getLogger("emd_falsify").setLevel("DEBUG")
This will print messages to your console reporting how much time each computation step is taking, which should help pin down the source of the issue.
Further work
The current implementation of the hierarchical beta process (used for sampling quantile paths) has seen quite a lot of testing for numerical stability, but little optimization effort. In particular it makes a lot of calls to functions in scipy.optimize, which makes the whole function quite slow: even with a relatively complicated data model like the pyloric circuit, drawing quantile paths can still take 10x longer than generating the data.
Substantial performance improvements to the sampling algorithm would almost certainly be possible with dedicated computer science effort. This sampling is the main bottleneck, any improvement on this front would also benefit the whole EMD procedure.
The hierarchical beta process is also not the only possible process for stochastically generating quantile paths: it was chosen in part because it made proving integrability particularly simple. Other processes may provide other advantages, either with respect to statistical robustness or computation speed.
Metadata
Release files for emd-falsify 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| emd_falsify-1.0.1.tar.gz | 103.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| emd_falsify-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 218.1 kB
Release files / emd_falsify-1.0.1.tar.gz
| Download URL | emd_falsify-1.0.1.tar.gz |
|---|---|
| Size | 103.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8221ff5a0ccd31a40d88d6afdaff9a06278fcc484279ac009a22a5348447ca5
|
|
BLAKE2b-256 checksum How to use checksums |
4022b6915111305f7439c5d5c1d9d0488c48205f3ed62737c8135ca99f483aec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / emd_falsify-1.0.1-py3-none-any.whl
| Download URL | emd_falsify-1.0.1-py3-none-any.whl |
|---|---|
| Size | 114.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55170824fbe238bc00416030b146c0de790bd7e0975ddb9b7f37fbb9a325137e
|
|
BLAKE2b-256 checksum How to use checksums |
414e3b13c6fe2c7a2199a17e9f68ac2f8f18348d12d3cd78aad06f513b150bf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for emd-falsify 1.0.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.