Probability Calibration

A model that says 0.8 should be right 80% of the time. Most are not, and AUC will never tell you.

Probability Calibration

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

A reliability diagram bins predictions by confidence and plots the observed frequency in each bin.
Perfect calibration is the diagonal. Below it means over-confident; above it means under-confident.
ECE is the average gap between confidence and observed frequency, weighted by bin size.
Calibration and ranking are independent. The slider changes calibration dramatically and leaves AUC untouched.

Overview

Suppose a model assigns about 0.8 to 100 cases. If roughly 80 are positive, those predictions are calibrated at that range. This says nothing about whether the model ranks individual cases well, and it does not mean any one case with score 0.8 has a known 80% outcome.

In this guide
  1. Calibration versus ranking
  2. Explore temperature scaling
  3. Calibration methods
  4. A simple calibration check
  5. Common mistakes with Probability Calibration
  6. Sources and next steps

A model can rank positives above negatives and have a strong ROC AUC while assigning probabilities that are systematically too high or too low. A reliability diagram checks calibration by comparing average predicted probability with the observed positive rate in bins. Points near the diagonal indicate agreement.

Explore temperature scaling

Move the temperature control and watch the reliability curve change. Temperature scaling divides logits by a positive constant before converting them to probabilities. A higher temperature softens predictions toward the middle; a lower one makes them more extreme. Because the transformation is monotonic, it preserves score order, so ranking metrics such as ROC AUC do not change (apart from tie effects). Probability-based metrics and threshold decisions can change.

The visualizer uses a fixed synthetic example to show the effect. In practice, estimate calibration corrections on held-out data or out-of-fold predictions, then assess them on separate data.

Calibration methods

  • Platt scaling: fits a logistic mapping from model scores to probabilities. It is compact and can work with modest calibration data when the score distortion is roughly sigmoid-shaped.
  • Temperature scaling: adjusts neural-network logits with one parameter and preserves their order.
  • Isotonic regression: fits a flexible monotonic mapping. It can model more shapes but needs enough calibration examples to avoid overfitting.

Calibration is model- and data-dependent. Logistic regression is not guaranteed to be calibrated, and random forests or neural networks are not guaranteed to be miscalibrated. Check the measured predictions rather than relying on model-family rules.

A simple calibration check

Imagine a bin of 100 predictions averaging 0.90, where 70 outcomes are positive. The bin is overconfident by 0.20. Expected calibration error (ECE) averages the absolute gap between confidence and observed rate across bins, weighted by bin size. ECE is convenient but depends on bin choices and can hide local errors; inspect the reliability curve and a proper score such as Brier score or log loss as well.

Common mistakes with Probability Calibration

  • Using training data to calibrate: the correction can fit training-specific errors.
  • Assuming high AUC means good probabilities: AUC measures ranking, not probability accuracy.
  • Reporting ECE alone: different binning can change it, and positive and negative local errors can be obscured.
  • Ignoring distribution change: calibration may drift as the population or measurement process changes.

Sources and next steps

Check yourself

0 of 3

Answer without scrolling back up.

  1. Why is AUC unchanged as the temperature slider moves?

  2. A reliability curve sits below the diagonal. The model is:

  3. When does calibration not matter?

Cheat sheet

Probability Calibration

Check whether predicted probabilities match observed frequencies. Apply Platt scaling and isotonic regression to close the gap.

MACHINE LEARNING · vizlearn.in/machine_learning/probability_calibration.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.