Calibration and Brier score
Quick answer
Calibration concerns whether predicted probabilities match observed frequencies. The binary Brier score averages squared probability errors, and reliability diagrams compare mean predictions with observed rates in bins. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Binary Brier score
from sklearn.metrics import brier_score_lossy=[0,1,1,1];p=[.1,.2,.7,.9]print(f"{brier_score_loss(y,p):.4f}")Observed local output:
0.1875The missed positive with p=.2 contributes .64 to the squared error sum.
How it works
For binary y in {0,1} and p in [0,1], Brier = mean((p-y)^2), ranging from 0 to 1. This proper scoring rule combines calibration and discrimination, so a lower Brier score alone does not prove better reliability. A reliability bin contains a count, mean predicted probability and observed fraction of positives. Equal-width bins use probability intervals; quantile bins target similar counts but ties can reduce the number of bins. Empty bins have no empirical fraction and should be omitted or marked undefined. Bins hide within-bin variation; report counts and uncertainty, especially for rare events. Compare against a training-prevalence constant on held-out data. Calibration is population-dependent and does not guarantee validity under shift. A ranking metric can stay constant after a strictly increasing transformation even when Brier changes.
Reliability bins
from sklearn.calibration import calibration_curvey=[0,0,1,1];p=[.1,.3,.7,.9]f,m=calibration_curve(y,p,n_bins=2)print(f.tolist(),m.round(2).tolist())Observed local output:
[0.0, 1.0] [0.2, 0.8]The two bins contain two rows each; observed frequencies differ from mean predictions.
Common mistakes
Do not interpret a reliability point based on one observation as proof. Do not estimate a baseline prevalence using test labels. Distinguish binary Brier convention from multiclass sum-of-squares conventions.
Practice and next steps
For probabilities .1,.2,.7,.9 and labels 0,1,1,1, calculate Brier and two bin averages by hand. Complete the knowledge check and staged exercise. Next: Platt and isotonic calibration.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Calibration and Brier score — knowledge check
Apply calibration and brier score to new scenarios.
Perfect binary probabilities have Brier?
Does lower Brier prove calibration alone improved?
What belongs beside reliability points?
What is an empty bin event rate?
Can calibration fail after distribution shift?