#86Brier Score + Reliability DecompositionMediumEvaluation MetricsAsked atMeta · Google · Microsoft
Brier Score + Reliability Decomposition
Background
The Brier score is the mean squared error of probabilistic predictions: . Decompose into reliability (calibration error) and resolution (sharpness) per bin to reason about which kind of miscalibration dominates.
Problem statement
Implement brier_score(probs, labels, n_bins=10) returning (brier, reliability, resolution).
Input
probs- array-like of floats in , length .labels- array-like of , length .n_bins- bins for the decomposition (default ).
Output
(brier, reliability, resolution)- tuple of plain Python floats.
Examples
Input: probs=[0.9, 0.1, 0.9, 0.1], labels=[1, 0, 1, 0], n_bins=2
Output: brier=0.01, reliability~0.01, resolution=0.25
Constraints
- Equal-width bins on with clamp at the last bin.
- Empty bins contribute 0 to both reliability and resolution.
Notes
- Identity. Brier = Rel - Res + Unc (uncertainty = ). Rel = 0 means perfectly calibrated; Res large means the bins differentiate outcomes well.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Two-bin decomposition, hand-checkable (example)
- •Full decomposition on two predictions (reference)
- •Full decomposition across five bins (sample)