Skip to main content

Uncertainty quantification and model inference for machine learning models

Project description

Version badge Python badge License badge Format badge Linting badge Test badge

ML Uncertainty

Compute prediction intervals and parameter uncertainties for ML models in 4 lines of code

ML Uncertainty is a Python module for machine learning inference build on top of scikit-learn and autograd packages, and is distributed under the MIT license.

This package has been built by Archit Datar (architdatar@gmail.com).

Intended audience

This package is intended to benefit data scientists and ML enthusiasts.

Motivation

  • Too often in machine learning, we fit complex models, but cannot quantity their precision via prediction intervals or feature significance.

  • This is especially true of the scikit-learn environment which is extremely easy to use but does not offer these functionalities.

  • However, in many use cases, especially where we have small and fat datasets, these are insights are critical to produce reliable models and insights.

  • Enter ML Uncertainty! This provides an easy API to get all these insights from models.

  • It takes scikit-learn fitted models as inputs and uses appropriate statistics to quantify the uncertainties in ML models.

Computing stats as easy as:

# Set up the model inference.
inf = ParametricModelInference()
inf.set_up_model_inference(X_train=X, y_train=y, estimator=regr)

# Get parameter importance estimates.
df_imp = inf.get_parameter_errors()

# Get prediction intervals.
df_int = inf.get_intervals(X)

Features

  1. Model parameter significance testing: Tests whether the given model parameters are truly significant or not.

    For ensemble models, it can inform if given features are truly important or if they just seem so due to the instability of the model.

  2. Prediction intervals: Can produce prediction and confidence intervals for parametric and non-parametric ML models.

  3. Error propagation: Propagates error from input / model parameters to the outputs.

  4. Non-Linear regression: Scikit-learn-style API to fit non-linear models.

Installation

Dependencies

Python versions: See badges above. Packages: See requirements.txt.

User installation

See ./docs/installation.md.

Examples

To run the examples, some additional plots need to be made which require matplotlib and seaborn packages. These can be installed using:

pip install matplotlib seaborn

Check out some of the these examples to try out the package. These examples are best run in VS code.

Theoretical foundations

Discussion about the theory used can be found here:

Benchmarking

NonLinearRegression, ParametricModelInference, and ErrorPropagation classes have been benchmarked against the Python statsmodels package. The codes for this can be found here.

To run these benchmarking codes, please install statsmodels using:

pip install statsmodels==0.14.0

The EnsembleModelInference does not have a code to benchmark it against to the best of my knowledge. However, the code follows the ideas developed in the work by Zhang et al. (2020). The test is that a $(1-\alpha)\times100$ % prediction interval must contain $(1-\alpha)$ proportion of the training data. See benchmarking codes here.

Credits

  1. This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage_ project template.

    Cookiecutter

    audreyr/cookiecutter-pypackage

  2. Some functions in ParametricModelInference are adopted from a Github repo by sriki18.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml_uncertainty-0.1.0.tar.gz (84.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ml_uncertainty-0.1.0-py2.py3-none-any.whl (36.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ml_uncertainty-0.1.0.tar.gz.

File metadata

  • Download URL: ml_uncertainty-0.1.0.tar.gz
  • Upload date:
  • Size: 84.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ml_uncertainty-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81aee96284c2dc4255cd9c3fbcfce3b91fe8dc800eaeaefc390f42061591166f
MD5 d90469e7f56d4b5a437218c05a720ca0
BLAKE2b-256 a3616a391839fc15c3177ddce2088927da792b5d43d82c0f17893cabfd4b8990

See more details on using hashes here.

File details

Details for the file ml_uncertainty-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ml_uncertainty-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ef12449e885c979e665726801d8bdb3d8310de9c923da038f220f40fdb1a6785
MD5 796abac238fc138e766d95bbd9b1f819
BLAKE2b-256 6252033019e9442d3aa8bbe7276480a81d7acbe38130357ac2bc4bd4c7906898

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page