Statistical note
Probability calibration, log loss, and Brier score
Evaluating whether predicted probabilities mean what they say, with proper scoring rules and reliability diagrams.
A classifier is calibrated when events assigned probability occur about a fraction of the time. The binary Brier score is
and log loss is
from sklearn.metrics import brier_score_loss, log_loss
from sklearn.calibration import calibration_curve
y_true = [0, 0, 0, 1, 1, 1]
prob = [0.05, 0.20, 0.70, 0.55, 0.80, 0.95]
print(brier_score_loss(y_true, prob))
print(log_loss(y_true, prob))
fraction_positive, mean_predicted = calibration_curve(y_true, prob, n_bins=3)
Case study: quality-control triage
If an imaging system sends samples above 0.8 probability for manual review, calibration determines whether “0.8” has operational meaning. Discrimination can be strong while probabilities are overconfident. Fit calibration only on data separate from model training and evaluate under the deployment prevalence.
Functions: sklearn.metrics.brier_score_loss, log_loss, and sklearn.calibration.calibration_curve.