Probability Calibration › Visualizing Probability Calibration

Michael BrenndoerferOctober 29, 20264 min read
Machine Learning from ScratchAll chapters
Part 12 of 15Calibration and Prediction Uncertainty
Chapter 76Probability Calibration › Visualizing Probability Calibration
Reading section 7 of 10 · Visualizing Probability Calibration · 4 minSection 7 of 10 · 4 min

Section 7 of 10 · 4 min read

Probability Calibration › Visualizing Probability CalibrationSection view · Sections in this chapter7 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

The reliability diagram is the main diagnostic for calibration. We compute it on the untouched test set. The deliberately sharpened raw scores illustrate scale miscalibration. The sigmoid map estimates a smooth correction, but its curve on the separate test partition need not lie on the diagonal. Isotonic recalibration can bend more sharply, but it can also create flat segments where many scores receive the same calibrated probability.

PythonIn [22]
CollapseExpand
reliability_curves = [
    (name, reliability_table(y_test, p, n_bins=10, strategy="quantile"))
    for name, p in [
        ("Raw", p_test_raw),
        ("Sigmoid", p_test_sig),
        ("Isotonic", p_test_iso),
    ]
]
VisualizationOut [23]
CollapseExpand
Reliability diagram comparing raw, sigmoid-calibrated, and isotonic-calibrated probabilities against observed positive rates.
Reliability diagram on the untouched test set comparing raw, sigmoid-calibrated, and isotonic-calibrated probabilities against observed positive rates. Points below the diagonal overpredict the positive-event rate; points above underpredict it.

The reliability diagram shows how closely predicted probabilities track observed rates across the probability scale.

The histogram shows where the probability mass sits. An overconfident classifier often places many test cases near zero or one. Calibration moves some of that mass toward the middle, but it does not necessarily make the distribution symmetric. The shape of the calibrated distribution depends on the fitted map and on the raw scores. We should not interpret a concentration near the base rate as a failure by itself; the relevant question is whether the observed rates in each region match the predicted probabilities.

VisualizationOut [24]
CollapseExpand
Overlaid histograms of raw, sigmoid-calibrated, and isotonic-calibrated predicted probabilities on the test set.
Distributions of raw and calibrated test-set probabilities. The histogram compares probability scales; ranking effects are checked separately.

The score comparison makes the distinction between calibration and discrimination concrete. The Brier score and log loss are proper scores that reward both calibration and separation. AUC is a ranking metric. A strictly increasing map preserves AUC before numerical clipping or saturation; nondecreasing isotonic maps can change ties. Proper scores may improve or worsen on new cases. In the chart, lower bars indicate better probability quality. Compare the methods on each score, then use the separate AUC table to check ranking. An estimated recalibrator can worsen a test score, and isotonic plateaus can change AUC by creating ties. If a method appears to improve AUC substantially, we should check for leakage, a change in the test set, or a nonmonotone map that is doing something other than calibration.

VisualizationOut [25]
CollapseExpand
Grouped bar chart comparing Brier score and log loss for raw, sigmoid-calibrated, and isotonic-calibrated models.
Brier score and log loss on the test set. Lower is better. The displayed scores evaluate probability quality, while AUC measures ranking.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy