Applied AI Vol. 1

Reading a Reliability Diagram: Is “80% Confident” Right 80% of the Time?

How to check whether a model’s probabilities mean what they say, and what expected calibration error can and cannot tell you.

Applied AI Vol. 1 · 5 min read

A classifier says it is 80% sure. If you collect all the cases where it said 80%, are about 80% of them correct? That is the question calibration asks.

Building the diagram

Group predictions into bins by predicted probability, for example 0.0 to 0.1, 0.1 to 0.2, and so on. In each bin, compute the average predicted probability and the fraction of cases that were actually positive. Plot one against the other.

A perfectly calibrated model lies on the diagonal. Points below the diagonal mean the model is overconfident. Points above mean it is underconfident.

Expected calibration error

Expected calibration error, or ECE, summarizes the diagram in one number: the weighted average, across bins, of the absolute gap between confidence and accuracy, with weights proportional to how many predictions fall in each bin.

It is easy to compute and easy to over-interpret.

Cautions

  • ECE depends on the binning. Different bin counts or edges give different numbers, so report the scheme.
  • Sparse bins are noisy. Show bin counts, and consider intervals on each point.
  • A model can have low ECE and still be useless. Always predicting the base rate is perfectly calibrated and tells you nothing about individual cases.
  • Calibration is not accuracy. Report discrimination, such as AUC, and a proper scoring rule such as the Brier score or log loss alongside it.

What to do when it looks bad

Overconfidence is common in modern neural networks. A simple post-hoc fix is often enough, which is the subject of the next guide on temperature scaling. Always fit the fix on a calibration split, and check it again on fresh data.

More guides from this book