Skip to content
mentoor

Topic 4 of 6 · 5 min read

Calibrated probabilities and reliability plots

Goal: Read a reliability diagram and decide whether a model's probabilities can be used as they are or need recalibration.

A model is calibrated when its predicted probabilities match how often the event really happens: among cases scored 0.8, about 80% should be positive. Ranking well and being calibrated are different properties, and any decision that uses the probability itself needs the second.

Check yourself · 1 of 3

A model is well calibrated. Among cases it scores near 0.7, what should you expect?

Choose one answer

Why it matters

If a loan model says "7% chance of default" and you set interest rates from that number, a model that says 7% for cases that default 20% of the time will lose money, even with excellent ROC-AUC. Triage, pricing, risk limits and "show only if above 90% confident" rules all depend on honest probabilities. Many models, including boosted trees and neural networks, produce scores that are over-confident or under-confident out of the box.

How to check

  1. Hold out data the model and any calibrator never saw.
  2. Bin predictions (for example into 10 bins by score) and compute, per bin, the mean predicted probability and the observed fraction of positives.
  3. Plot observed against predicted. The diagonal is perfect calibration. A curve below the diagonal means the model is over-confident: it says 0.9 and the truth is 0.7.
from sklearn.calibration import calibration_curve
frac_pos, mean_pred = calibration_curve(y_val, p_val, n_bins=10)

Two numbers help. The Brier score is the mean of (p - y)², so lower is better; it rewards both discrimination and calibration. Expected calibration error is the weighted average gap between the bars and the diagonal. Both depend on binning or sample size, so also look at the plot.

Fixing it

Recalibrate on a separate calibration set (or with cross-validation): Platt scaling fits a sigmoid on the scores and suits small data; isotonic regression fits a free-form monotone curve and needs more data to avoid overfitting. Recalibration usually leaves ROC-AUC unchanged because it keeps the ranking.

Before and after

Before: "The model gives 0.9 for 400 cases, so we auto-approve above 0.9." After a reliability check: those 400 cases were positive 71% of the time. The team recalibrates, then sets the auto-approve threshold at the score where the observed rate is 95%.

What goes wrong

  • Calibrating on the training data. The curve then looks perfect and means nothing.
  • Sparse bins. A bin with 8 samples gives a noisy point; plot counts or use fewer bins.
  • Drift. A model calibrated last year can be miscalibrated after the population changes; re-check on recent data.
  • Reading AUC as calibration. A model can rank perfectly and still output 0.99 for every positive and 0.98 for every negative.

Examples

Reading a reliability table

Score bin 0.8 to 0.9 has 200 validation cases and 128 positives: observed rate 0.64 against a mean prediction of 0.85. The model is over-confident in that range. Using 0.85 as a risk estimate would overstate risk by about a fifth. Fit a recalibrator on separate data, then re-check.

Same ranking, different probabilities

Model A gives positives 0.6 and negatives 0.4. Model B gives positives 0.99 and negatives 0.98. Both rank every positive above every negative, so both have ROC-AUC 1.0. Only A can plausibly be calibrated if about 60% of its high group is positive. Thresholds read from B's probabilities would be meaningless.

Key points

  • A calibrated model's predicted probability matches the observed frequency of the event in each score range.
  • A reliability curve below the diagonal means over-confidence; above it means under-confidence.
  • Brier score is the mean squared difference between probability and outcome, lower is better.
  • Platt scaling and isotonic regression fix calibration on a separate held-out set and keep the ranking.
  • Good ROC-AUC does not imply calibrated probabilities.

Common mistakes

  • Fitting the recalibrator and checking calibration on the same data.
  • Judging a reliability plot from bins with only a handful of samples.
  • Assuming a high ROC-AUC means the probabilities can be used as risks.
  • Never re-checking calibration after the input population changes.

Check yourself · 2 of 3

On a reliability plot the curve lies well below the diagonal in the high-score region. What does that mean?

Choose one answer

Check yourself · 3 of 3

A model has strong ROC-AUC but over-confident probabilities. What is a sensible fix?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic