Uncertainty Toolbox: a python toolbox for predictive uncertainty quantification, calibration, metrics, and visualization.
Project description
Uncertainty Toolbox
A Python toolbox for predictive uncertainty quantification, calibration, metrics, and visualization.
Also: a glossary of useful terms and a collection of relevant papers and references.
Many machine learning methods return predictions along with uncertainties of some form,
such as distributions or confidence intervals. This begs the questions: How do we
determine which predictive uncertanties are best? What does it mean to produce a best
or ideal uncertainty? Are our uncertainties accurate and well calibrated?
Uncertainty Toolbox provides standard metrics to quantify and compare predictive uncertainty estimates, gives intuition for these metrics, produces visualizations of these metrics/uncertainties, and implements simple "re-calibration" procedures to improve these uncertainties. This toolbox currently focuses on regression tasks.
Toolbox Contents
Uncertainty Toolbox contains:
- Glossary of terms related to predictive uncertainty quantification.
- Metrics for assessing quality of predictive uncertainty estimates.
- Visualizations for predictive uncertainty estimates and metrics.
- Recalibration methods for improving the calibration of a predictor.
- Paper list: publications and references on relevant methods and metrics.
Installation
Uncertainty Toolbox requires Python 3.6+ and pip ≥ 21.3. For a lightweight installation of the package only, run:
pip install uncertainty-toolbox
For a full installation with examples, tests, and the latest updates, run:
git clone https://github.com/uncertainty-toolbox/uncertainty-toolbox.git
cd uncertainty-toolbox
pip install -e . -r requirements/requirements_dev.txt
To verify correct installation, you can run the test suite via:
source shell/run_all_tests.sh
Quick Start
import uncertainty_toolbox as uct
# Load an example dataset of 100 predictions, uncertainties, and ground truth values
predictions, predictions_std, y, x = uct.data.synthetic_sine_heteroscedastic(100)
# Compute all uncertainty metrics
metrics = uct.metrics.get_all_metrics(predictions, predictions_std, y)
This example computes metrics for a vector of predicted values
(predictions
) and associated uncertainties (predictions_std
, a vector of standard
deviations), taken with respect to a corresponding set of ground truth values y
.
Colab notebook: You can also take a look at this Colab notebook, which walks through a use case of Uncertainty Toolbox.
Metrics
Uncertainty Toolbox provides a number of metrics to
quantify and compare predictive uncertainty estimates. For example, the
get_all_metrics
function will return:
- average calibration: mean absolute calibration error, root mean squared calibration error, miscalibration area.
- adversarial group calibration: mean absolute adversarial group calibration error, root mean squared adversarial group calibration error.
- sharpness: expected standard deviation.
- proper scoring rules: negative log-likelihood, continuous ranked probability score, check score, interval score.
- accuracy: mean absolute error, root mean squared error, median absolute error, coefficient of determination, correlation.
Visualizations
The following plots are a few of the visualizations provided by Uncertainty Toolbox. See this example for code to reproduce these plots.
Overconfident (too little uncertainty)
Underconfident (too much uncertainty)
Well calibrated
And here are a few of the calibration metrics for the above three cases:
Mean absolute calibration error (MACE) | Root mean squared calibration error (RMSCE) | Miscalibration area (MA) | |
---|---|---|---|
Overconfident | 0.19429 | 0.21753 | 0.19625 |
Underconfident | 0.20692 | 0.23003 | 0.20901 |
Well calibrated | 0.00862 | 0.01040 | 0.00865 |
Recalibration
The following plots show the results of a recalibration procedure provided by Uncertainty Toolbox, which transforms a set of predictive uncertainties to improve average calibration. The algorithm is based on isotonic regression, as proposed by Kuleshov et al.
See this example for code to reproduce these plots.
Recalibrating overconfident predictions
Mean absolute calibration error (MACE) | Root mean squared calibration error (RMSCE) | Miscalibration area (MA) | |
---|---|---|---|
Before Recalibration | 0.19429 | 0.21753 | 0.19625 |
After Recalibration | 0.01124 | 0.02591 | 0.01117 |
Recalibrating underconfident predictions
Mean absolute calibration error (MACE) | Root mean squared calibration error (RMSCE) | Miscalibration area (MA) | |
---|---|---|---|
Before Recalibration | 0.20692 | 0.23003 | 0.20901 |
After Recalibration | 0.00157 | 0.00205 | 0.00132 |
Contributing
We welcome and greatly appreciate contributions from the community! Please see our contributing guidelines for details on how to help out.
Citation
If you found this toolbox helpful, please cite the following paper:
@article{chung2021uncertainty,
title={Uncertainty Toolbox: an Open-Source Library for Assessing, Visualizing, and Improving Uncertainty Quantification},
author={Chung, Youngseog and Char, Ian and Guo, Han and Schneider, Jeff and Neiswanger, Willie},
journal={arXiv preprint arXiv:2109.10254},
year={2021}
}
Additionally, here are papers that led to the development of the toolbox:
@article{chung2020beyond,
title={Beyond Pinball Loss: Quantile Methods for Calibrated Uncertainty Quantification},
author={Chung, Youngseog and Neiswanger, Willie and Char, Ian and Schneider, Jeff},
journal={arXiv preprint arXiv:2011.09588},
year={2020}
}
@article{tran2020methods,
title={Methods for comparing uncertainty quantifications for material property predictions},
author={Tran, Kevin and Neiswanger, Willie and Yoon, Junwoong and Zhang, Qingyang and Xing, Eric and Ulissi, Zachary W},
journal={Machine Learning: Science and Technology},
volume={1},
number={2},
pages={025006},
year={2020},
publisher={IOP Publishing}
}
Acknowledgments
Development of Uncertainty Toolbox is supported by the following organizations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file uncertainty-toolbox-0.1.1.tar.gz
.
File metadata
- Download URL: uncertainty-toolbox-0.1.1.tar.gz
- Upload date:
- Size: 656.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9389112bd431edc8b6e44c5b12405dea8f86063ff9b79f0bb178e5ac76bcfa5 |
|
MD5 | 66dfa79730489f48d006fb05e83045cb |
|
BLAKE2b-256 | 38fc0cd4e9fa54fef09aec94d03df79f9103aeddf2351415250629882bb2f325 |
File details
Details for the file uncertainty_toolbox-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: uncertainty_toolbox-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aebd0ab174f15a06f1c63c6172dd24ace2b7a4ba5610c3ee5a186bf5669cf24 |
|
MD5 | 47b2bb21299aab6170004db8c475688c |
|
BLAKE2b-256 | 40d3ec5faa64fc6b0c4c81488939439cb9c49af4e37262778d0758cb1a909c45 |