Speed

What Calibration Bins Do and Do Not Say

Separate calibration (honest frequencies per bucket) from sharpness and discrimination using the squared Brier score against the constant base rate.

The problem

Zero calibration error sounds like the finish line for probabilistic forecasting, yet a trivial forecaster achieves it without reading a single feature. On a dataset where half the rows finish positive (base = 0.50), predicting 0.50 on every row puts all ten rows into one bucket whose predicted mean (0.50) matches its observed fraction (5 / 10 = 0.50) with 0.0 calibration gap.

Now compare that constant 0.50 baseline against a sharp forecaster on ten rows [p, y]: four (0.20, 0) rows plus one (0.20, 1) row in the low group, and one (0.80, 0) row plus four (0.80, 1) rows in the high group. Both buckets are also calibrated (1 / 5 = 0.20 and 4 / 5 = 0.80). How do we measure the extra discrimination that calibration bins alone leave unsaid?

Work through the numbers

The Brier score averages squared probability residuals across all n = 10 rows:

Brier=1n∑i=1n(pi−yi)2 \mathrm{Brier} = \frac{1}{n}\sum_{i=1}^{n} (p_i - y_i)^2

For the constant baseline base = 0.50, every row lies 0.50 away from 0 or 1, so (0.50 - y)^2 = 0.25 on each row and brier_base = 2.50 / 10 = 0.25.

For the sharp forecaster (blend = 1.0), eight of the ten rows—the four (0.20, 0) rows and four (0.80, 1) rows—miss by 0.20, contributing 8 * (0.20)^2 = 8 * 0.04 = 0.32. The remaining two rows—(0.20, 1) and (0.80, 0)—miss by 0.80, contributing 2 * (0.80)^2 = 2 * 0.64 = 1.28. Summing 0.32 + 1.28 = 1.60 and dividing by 10 yields brier_model = 0.16.

Subtracting brier_model from brier_base gives brier_gain = 0.25 - 0.16 = 0.09. Notice that 0.09 equals (0.30)^2, the squared distance by which the calibrated bucket means (0.20 and 0.80) pull away from the 0.50 base rate.

The live model

The top strip shows the blended forecasts pb = base + blend * (p - base) spreading outward from the grey 0.50 base-rate line. At blend = 1.0, brier_model (0.16) beats brier_base (0.25) by brier_gain = 0.09. Slide blend to 0.5 (pb = 0.35 and 0.65) to watch brier_model rise to 0.1825 (gain = 0.0675), or all the way down to 0.0 where every dot collapses onto 0.50 (brier_model = 0.25, gain = 0).

Sharp calibrated forecasts at 0.2 and 0.8 achieve Brier score 0.16 against calibrated constant 0.5 forecasts at Brier score 0.25 (gain 0.09).
let blend = scene.parameter("blend", 1.0, 0.0, 1.0, 0.25);
let p = input.select(1, 0);
let y = input.select(1, 1);
let n = float(p.numel());
let base = y.sum().div(n);
let pb = base + (p - base) * blend;
let err_m = pb - y;
let err_b = y - base;
let brier_model = (err_m * err_m).sum().div(n);
let brier_base = (err_b * err_b).sum().div(n);
let brier_gain = brier_base - brier_model;
let items = torch.list().add(brier_model).add(brier_base).add(brier_gain);
let answer = torch.stack(items, 0);
out.set("brier_model", brier_model.item()).set("brier_gain", brier_gain.item());
{
  "brier_model": 0.16000000000000006,
  "brier_gain": 0.08999999999999994
}
Watch the parameter change

Your turn

Comparing a sharp forecaster against the constant base-rate baseline requires the strictly proper Brier score rather than mean absolute residual. The starting code reports mean absolute errors [0.32, 0.5, 0.18], which would reward rounding probabilities toward 0 and 1 instead of reporting honest calibrated rates. Return [brier_model, brier_base, brier_gain]. Check evaluates unseen datasets with non-half base rates and fractional blend.

Starter computes mean absolute residual (0.32 vs 0.50) instead of mean squared Brier score (0.16 vs 0.25).
let blend = scene.parameter("blend", 1.0, 0.0, 1.0, 0.25);
let p = input.select(1, 0);
let y = input.select(1, 1);
let n = float(p.numel());
let base = y.sum().div(n);
let pb = base + (p - base) * blend;
let err_m = pb - y;
let err_b = y - base;
let brier_model = err_m.abs().sum().div(n);
let brier_base = err_b.abs().sum().div(n);
let brier_gain = brier_base - brier_model;
let items = torch.list().add(brier_model).add(brier_base).add(brier_gain);
let answer = torch.stack(items, 0);
out.set("brier_model", brier_model.item()).set("brier_gain", brier_gain.item());
{
  "brier_model": 0.3200000000000001,
  "brier_gain": 0.17999999999999988
}

Evaluate both the blended forecast and the constant base-rate baseline with the proper Brier score rather than mean absolute error, which reports [0.32, 0.5, 0.18] in the starter. Return [brier_model, brier_base, brier_gain].

Once proper Brier scores are computed, [brier_model, brier_base, brier_gain] settles on [0.16, 0.25, 0.09].

Read the result carefully

Calibration bins answer one specific question: when the model announces probability q, does the outcome occur q of the time? They do not measure sharpness (how far forecasts move toward 0 and 1) or resolution (how well buckets separate different empirical rates). Proper scoring rules such as Brier score and log-loss reward a model only when it is both honest (calibrated) and informative (sharp).

Recap

  • Calibration checks conditional honesty (obs_frac matches mean_pred) and can be satisfied by predicting the constant base rate everywhere.
  • Calibration bins alone do not measure discrimination or sharpness unless you also inspect how far bucket rates spread from base.
  • Squared Brier score (mean((p - y)^2)) combines calibration penalty and resolution gain into one strictly proper metric.