Field notes · Trustworthy AI made clear
Uncertainty quantification explained for researchers
A model that says "malignant" gives you an answer. Uncertainty quantification asks a second question: how much should you trust that answer? This is a plain map of the field, written for researchers who use deep learning, not only for specialists.
Uncertainty quantification, explained for researchers
The short version on four printable pages: the words you need, a method chooser with costs, a test checklist, and a sample paragraph for your methods section.
What uncertainty quantification is
Uncertainty quantification, or UQ, is the set of methods that attach a measure of doubt to each prediction. Instead of a label alone, the model gives a label and a score, an interval, or a set of possible labels that says how sure it is.
That score is useful only if it means something. A good uncertainty estimate is high when the model is likely to be wrong, and low when it is likely to be right. Keep this test in mind. Everything below comes back to it.
Why it matters for your research
- Decisions. In medicine and other high stakes fields, people act on the output. They need to know which answers to check.
- Honest results. A model with 90 percent accuracy is still wrong one time in ten. Uncertainty helps point to the cases that are likely to be wrong.
- Peer review. Reviewers often ask how a model behaves on hard or unfamiliar cases. "We did not measure it" is a weak answer.
Two kinds of uncertainty
Not all uncertainty has the same cause. Researchers usually separate two kinds.
Noise in the data itself. An ambiguous image stays ambiguous. More data of the same kind does not remove it.
What the model has not learned. It is high on unfamiliar inputs, and it can shrink with more or better data.
The difference tells you what to do next. I explain it with mammography examples in aleatoric versus epistemic uncertainty.
Uncertainty of a prediction, and uncertainty of your results
There is a second distinction that is easy to mix up.
- Uncertainty of a prediction. How sure the model is about one case. This is what UQ methods estimate.
- Uncertainty of your results. How sure you are about a metric such as accuracy or AUC, given the size of your test set. This is a confidence interval. It comes from statistics, not from the model.
A paper needs both. An AUC measured on a small test set comes with a wide interval. A simple way to estimate it is the bootstrap: resample the test set many times with replacement, recompute the metric each time, and look at the spread. If one patient has several images, resample patients, not images.
The main methods, in plain words
- Softmax confidence. Use the highest predicted probability as the confidence. It costs nothing, and it is the baseline every other method should beat. Hendrycks and Gimpel showed that correct predictions tend to get a higher maximum probability than wrong ones. On its own, it is often overconfident.
- Temperature scaling. Divide the output scores by one number fitted on validation data, so the probabilities match the observed accuracy better. It does not change which class is predicted, so accuracy stays the same. Guo and colleagues found it works well on most of the datasets they tested. See model calibration and ECE explained.
- Monte Carlo dropout. Keep dropout switched on at test time and run each input several times. The spread of the outputs estimates epistemic uncertainty. Gal and Ghahramani linked this to approximate Bayesian inference. The cost is many forward passes per input.
- Deep ensembles. Train several networks from different random starts and measure how much they disagree. Lakshminarayanan and colleagues presented this as a simple and scalable method with high quality uncertainty estimates. The cost is several trained models.
- Predicting the noise. Train the network to output a noise estimate along with its prediction. This targets aleatoric uncertainty, as described by Kendall and Gal.
- Conformal prediction. Turn the scores of any trained model into a set of labels, such as "benign or malignant", that contains the true label at a rate you choose, for example 90 percent. The guarantee holds on average over cases, and it assumes the new data come from the same source as the calibration data. Angelopoulos and Bates give a gentle introduction.
There is no single best method. A sensible start for most projects: report softmax confidence, add temperature scaling, then compare with a deep ensemble or MC dropout if your budget allows. For the wider landscape, see the review by Abdar and colleagues.
How to test an uncertainty estimate
An uncertainty estimate is a claim, so test it like one.
- Calibration. Show a reliability diagram and the expected calibration error, and state how you binned the predictions.
- Error detection. Check that uncertainty separates wrong predictions from correct ones, for example with the AUROC for detecting misclassified cases.
- Risk and coverage. Let the model abstain on its least certain cases, and plot the error on the answered cases against the share it answers. This is the risk coverage curve from selective prediction in medical AI.
- New data. Test on data from another hospital, scanner, or site. Epistemic uncertainty should rise.
- Proper scores. Report the negative log likelihood or the Brier score next to accuracy or AUC.
Five common mistakes
- Fitting the temperature or choosing the abstention threshold on the test set.
- Reporting ECE without accuracy or AUC. A useless model can be well calibrated.
- Calling the softmax probability "uncertainty" without testing it.
- Testing only on data from the same source as the training data.
- Reporting a metric as a single number, with no confidence interval.
Where to start
If you are adding uncertainty to a project for the first time, start small. Compute the softmax baseline, draw a reliability diagram, and add bootstrap intervals to your main metric. That alone makes most papers stronger. Then add one real UQ method and compare it with the baseline.
This is the core of my own research on breast cancer detection in mammography: a model should be accurate, and it should also know when it should not be trusted. The publications are on the research page, and the free UQ kit puts this whole guide on four pages you can print.
References
D. Hendrycks and K. Gimpel, “A baseline for detecting misclassified and out of distribution examples in neural networks,” arXiv:1610.02136, 2016. doi.org/10.48550/arXiv.1610.02136
C. Guo, G. Pleiss, Y. Sun, K. Q. Weinberger, “On calibration of modern neural networks,” Proceedings of the 34th International Conference on Machine Learning, PMLR 70, pp. 1321 to 1330, 2017. proceedings.mlr.press/v70/guo17a.html
Y. Gal and Z. Ghahramani, “Dropout as a Bayesian approximation: representing model uncertainty in deep learning,” Proceedings of the 33rd International Conference on Machine Learning, PMLR 48, pp. 1050 to 1059, 2016. proceedings.mlr.press/v48/gal16.html
B. Lakshminarayanan, A. Pritzel, C. Blundell, “Simple and scalable predictive uncertainty estimation using deep ensembles,” arXiv:1612.01474, 2016. doi.org/10.48550/arXiv.1612.01474
A. Kendall and Y. Gal, “What uncertainties do we need in Bayesian deep learning for computer vision?,” arXiv:1703.04977, 2017. doi.org/10.48550/arXiv.1703.04977
A. N. Angelopoulos and S. Bates, “A gentle introduction to conformal prediction and distribution free uncertainty quantification,” arXiv:2107.07511, 2021. doi.org/10.48550/arXiv.2107.07511
M. Abdar et al., “A review of uncertainty quantification in deep learning: techniques, applications and challenges,” Information Fusion, vol. 76, pp. 243 to 297, 2021. doi.org/10.1016/j.inffus.2021.05.008
Free kit
Uncertainty quantification, explained for researchers.
Four printable pages: the words, a method chooser, a test checklist, and what to write in your paper. Free, no email, no sign-up.
Writing a paper right now? Take the two minute readiness check.
Keep reading
Aleatoric vs epistemic uncertainty: what a model does not know, and why
Two kinds of "I am not sure": noise in the data, and gaps in the model. Plain examples, how to estimate each, and what to do with them.
8 min readTrustworthy AI made clearWhy a model's confidence is often wrong: calibration and ECE explained
Accuracy says how often a model is right. Calibration says whether its confidence can be believed. How to measure it, and what to report.
8 min read