E ExamMaster

Artificial Intelligence · AI Foundations

Probability Calibration

In AI because a score only earns the name probability if the world agrees with it at that rate — decisions priced on miscalibrated scores are silently wrong.

A model that prints 0.9 is making a promise: of the cases it scores 0.9, about ninety in a hundred should come true. This lesson is about when that promise holds — how to check it with a reliability diagram, why ranking quality and probability quality are different achievements, and how to repair the numbers without retraining the model.

  • Artificial Intelligence
  • Medium level
  • 6 concepts

1What a probability promises

A score becomes a probability only by matching frequency: among all the predictions to which the model assigned 0.9, about 90% should come true. That property is calibration, and nothing about a model's architecture grants it automatically — a number between 0 and 1 is not a probability just because of where it lives.

It matters the moment scores price decisions. Expected-cost triage, medical thresholds, an auto-approve-above-0.95 rule — each multiplies someone's cost by the printed number, and a miscalibrated 0.95 that delivers 0.7 misprices every case it touches.

Calibration is checked, never assumed: it is a claim about the world's agreement with the model, so it can only be measured against outcomes — held-out ones.

Figure. Among predictions assigned 0.9, about 90% should come true — that match is calibration. A miscalibrated 0.95 that delivers 0.7 misprices every expected-cost decision it touches.

A model prints 0.9 for a batch of cases and turns out to be right on 6 of every 10 of them. What is the problem?
  1. It is miscalibrated: the number it reports is not the frequency it delivers
  2. Its accuracy is simply too low to be of use
  3. It has by definition overfitted the training data
  4. Its decision threshold has been left at 0.5 instead of 0.9

A probability is a claim about long-run frequency. Sixty per cent right in a bucket labelled ninety means the number cannot be used as a probability, however the ranking behaves.

2The reliability diagram

The calibration check made systematic: collect held-out predictions, group them into buckets by predicted probability, and for each bucket plot the observed frequency of the event against the predicted value. A perfectly calibrated model traces the diagonal — it delivers what it says at every level.

The signature shapes are worth recognising on sight. An overconfident model bows below the diagonal at the high end and above it at the low end: its 0.9s deliver less than 0.9 and its 0.1s more than 0.1. Underconfidence bows the other way. Naive Bayes typically draws an aggressively overconfident curve; a well-regularised logistic model often hugs the diagonal.

Buckets trade resolution against noise — ten equal-width bins is the usual start, and a bucket holding three cases says almost nothing. Scalar summaries such as the Brier score compress the curve into one number, at the usual price of hiding where the failure lives.

Figure. Held-out predictions bucketed by predicted probability. The dashed diagonal is a model that delivers what it says. The solid curve is overconfident: above the diagonal at the low end (its 0.1s come true more than a tenth of the time), crossing at 0.5, and flat at the top — the bucket predicted 0.9 delivers only 0.6.

Building one

  1. Score held-out casesCollect predictions the fit never saw, together with their outcomes.
  2. Bucket by claimGroup predictions into bins by predicted probability — ten equal bins to start.
  3. Compare per bucketPlot observed frequency against claimed probability; the diagonal is the promise kept.

Coding lab. Bucket the promises runs in the app, with checks on your output.

3Calibration is not discrimination

Two separate achievements hide inside 'the model is good'. Discrimination is ranking: do positives get higher scores than negatives? It is what AUC measures. Calibration is truth-telling: do the scores mean their face value? A model can hold either property without the other.

Naive Bayes is the standing example of one side — often an excellent ranker whose probabilities saturate toward 0 and 1. The other side exists too: a model that predicts the base rate for every case is perfectly calibrated and completely useless, because it never separates anyone from anyone.

AUC does not move when scores are monotonically rescaled; calibration does. That asymmetry is the practical hinge: bad calibration is repairable after the fact by a monotone map, while bad ranking is not — no rescaling can reorder what is already ordered.

Two questions
PropertyQuestionMeasured bySurvives monotone rescaling?
DiscriminationAre positives ranked above negatives?AUC and ranking metricsyes
CalibrationDoes 0.9 mean 90%?reliability diagram, Brier scoreno

4Where miscalibration comes from

Miscalibration has causes, and knowing them tells you where to look. Correlated evidence double-counted — the naive Bayes mechanism — pushes scores toward the extremes. Overfitting does the same: a model that has memorised its training set has watched every training case resolve, and its confidence reflects that private certainty rather than the world.

Modern deep networks are famously overconfident even when highly accurate — trained long enough, the loss keeps rewarding sharper probabilities on cases the model already gets right.

And a model calibrated at deployment does not stay calibrated: when the base rate or the population drifts, the prior baked into its scores becomes the wrong prior — exactly the effect the base-rate lesson computed. The common thread is that calibration fails whenever the model's training experience differs from the question's context: too-dependent evidence, too-familiar data, or a shifted world.

Figure. Correlated features re-submit the same signal. Overfit models report private certainty from memorised training cases. Base-rate drift makes yesterday's calibrated score today's mispriced one. All three push scores toward the extremes.

The usual suspects

  1. Double-counted evidenceCorrelated features re-submit the same signal; scores saturate toward 0 and 1.
  2. Memorised training dataOverfit models report their private certainty, not the world's frequency.
  3. A shifted worldBase-rate drift makes yesterday's calibrated score today's mispriced one.

5Repairing the scores

Because ranking survives monotone maps, a miscalibrated model can be repaired without retraining: learn a monotone function from its scores to honest probabilities on a held-out calibration set, and compose it on top. The ranking — and therefore AUC — is untouched; only the numbers change.

Three standard tools. Platt scaling fits a tiny logistic curve on the scores — two parameters, workable with little data. Isotonic regression fits any monotone step function — more flexible, and it needs more data to avoid overfitting the repair itself. Temperature scaling, the neural-network favourite, divides the score's logit by one learned constant T above 1 to soften overconfident outputs.

The non-negotiable: fit the repair on data the model was not trained on. Calibrating against training outcomes measures the model's memory, not its honesty.

One temperature, softer promises

A network's raw output for a case has logit 2.2, i.e. sigmoid(2.2) ≈ 0.90. Temperature scaling on a validation set chose T = 2.

  • Before: sigmoid(2.2)0.900
  • After: sigmoid(2.2 / 2) = sigmoid(1.1)0.750
  • Every case's logit divides by the same Torder unchanged — AUC identical, promises softened

Pro tip. One shared constant cannot fix a curve that crosses the diagonal — temperature scaling softens or sharpens everything uniformly. If the reliability curve is S-shaped, reach for isotonic regression instead.

6Held-out or it didn't happen

Every claim in this lesson — a reliability curve, a Brier score, a fitted temperature — is only evidence when computed on outcomes the model never trained on. Scores checked against training outcomes measure memory; the promise a probability makes is about cases the model has not seen.

The working discipline: split before anything is fit; fit on the training set; choose settings and fit any repair on validation data; quote final numbers on a test set touched once. The ML course formalises this as the train/validation/test contract, and every serious result you will report lives inside it.

Calibration is also not a one-time certificate. Deployed models drift with the world, so production systems re-check the reliability curve on fresh outcomes — which is monitoring, and it is where this course's final lesson on governance picks up.

Which data may answer which question
QuestionData allowed
Fit the modeltraining set
Choose settings, fit the repairvalidation set
Quote the final numbertest set, touched once
Is it still calibrated in production?fresh outcomes, continuously

Notes

  • A score is calibrated when events predicted at p happen with frequency p; the reliability diagram is the check.
  • Calibration and discrimination are separate achievements: AUC survives monotone rescaling, calibration does not.
  • Miscalibration is repairable without retraining — Platt scaling, isotonic regression or temperature scaling fitted on held-out data.

Formulas

  • Brier score = mean of (predicted − outcome)²
  • temperature scaling: p = sigmoid(logit / T)

Exam traps & shortcuts

  • Never validate calibration on training outcomes — a memorised case always resolves the way the model expects.
  • Before recalibrating, look at the reliability curve's shape: one temperature cannot fix a curve that crosses the diagonal.
  • A perfectly calibrated model can be useless — predicting the base rate for everyone keeps every promise and separates no one.

Recap

This lesson in brief:

The promise
A score is calibrated when events predicted at p happen with frequency p — checked against held-out outcomes, never assumed.
The reliability diagram
Bucket held-out predictions and plot delivered frequency against the claim; overconfidence bows below the diagonal at the high end.
Two separate achievements
AUC measures ranking and survives monotone rescaling; calibration measures truth-telling and does not.
Repair without retraining
Platt, isotonic or temperature scaling fit a monotone map on held-out data — ranking untouched, promises corrected.

Practise Probability Calibration

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • 1 quick check with worked explanations
  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.