ConceptsINTERNALS.md

Calibration

Whether a model’s “90% sure” can be trusted as a probability, which decides whether you can build a rule on it.

  • A model says it is 90% sure. Calibration asks whether it is right about 90% of the time when it says that.
  • To check, group its decisions by stated confidence and count how often each group is right.
  • If every group lands on the diagonal, the numbers work as probabilities.
  • Most models start out overconfident, and one number, a temperature, often fixes it.

Try this: drag the temperature from 1 to 2 and watch the orange bars climb up to the dashed line.

Try it

This page needs JavaScript.

What just happened

  1. The model makes yes or no decisions. For each it reports a confidence: the larger of its probability of yes and of no, between 50% and 100%.
  2. The decisions are grouped by stated confidence, in steps of five points. For each group, the bar shows how often the model is actually right. A calibrated model has every bar on the dashed diagonal.
  3. At temperature this model is overconfident. Of the decisions it calls or more, it says on average and is right of the time. The expected calibration error, the average gap weighted by group size, is .
  4. Dividing the raw scores by a temperature before they become probabilities softens them. At the error here falls to . This is temperature scaling. It never changes which answer wins, only how sure the model sounds.
How the toy is built

Each decision has a raw score z. The model reports a probability of sigmoid(z / T). The real chance that its call is right is sigmoid(|z| / 2) for every decision, so it is calibrated exactly at T = 2. A real model has no known right temperature, so it is fitted on held-out data. The 1,000 decisions are evenly spaced samples of a bell curve, and the bars show expected accuracy, so nothing on the page is random.

A common alternative is to report the single number above, the expected calibration error, or the Brier score, which also rewards sharp and correct answers. A model that always says 50% is perfectly calibrated and useless, so calibration is something to check alongside accuracy.

Where you meet it

Anywhere a number from a model becomes a rule. A confidence threshold in an agent, a model that decides whether to ask for help, a forecast that someone plans around. Guo and others showed that modern neural networks are often poorly calibrated, and that temperature scaling is a simple and effective fix.

Where it breaks

A temperature is tuned on one kind of input. Move to a harder kind and the model is overconfident again. Set the temperature to 2, then switch the inputs to a new kind.

At temperature the error is on the inputs it was tuned on and on the new kind, where the real temperature is . Among its most confident decisions there it says and is right of the time. A calibration claim is a statement about a group of decisions from a particular distribution. It says nothing about your inputs until you check them.

Check yourself

A model says 90% on 100 decisions and is right on 75. Is it calibrated?

No. It is overconfident by 15 points in that group. With only 100 decisions the 75 has some noise, which is why calibration checks use many decisions and groups of enough size.

Does temperature scaling change which option the model picks?

No. Dividing every score by the same positive number keeps their order, so the top option stays on top. Accuracy is unchanged. Only the probabilities move.

A vendor says its decision model is calibrated. What would you check before relying on it?

Run it on a sample of your own decisions, with known right answers, and plot how often it is right at each stated confidence. A claim measured on someone else’s data may not hold on yours.

Used in

Go deeper