Library · Credit scoring

Brier score and log loss

The Brier score and the log loss both score predicted probabilities against what happened, and both are proper: the best expected score goes to the true probability. They differ in how hard they punish a confident mistake.

By , published

Definition

For a predicted probability p and an outcome y equal to 0 or 1:

Brier = mean( (p − y)2 )    log loss = − mean( y ln p + (1 − y) ln(1 − p) )

The Brier score, introduced by Brier in 1950 for weather forecasts, lies between 0 and 1. The log loss has no upper limit: predicting 0 for an event that happens costs an infinite amount. Both are minimised in expectation by the true probability, the property Gneiting and Raftery call strictly proper. To read a Brier score, compare it with that of a forecast that always predicts the base rate: the Brier skill score is 1 minus the ratio of the two.

Worked example

Four sets of probabilities for the same rare event, with a base rate near 3 %.

import numpy as np

rng = np.random.default_rng(25)
n = 200_000
z = rng.normal(-4.0, 1.2, n)
p_true = 1 / (1 + np.exp(-z))
y = (rng.random(n) < p_true).astype(int)
base = y.mean()

forecasts = {
    "always the base rate":        np.full(n, base),
    "true probabilities":          p_true,
    "overconfident (too extreme)": 1 / (1 + np.exp(-(1.8 * z + 2.6))),
    "always zero":                 np.full(n, 1e-6),
}
ref = np.mean((base - y) ** 2)
print(f"base rate = {base:.4f}")
for name, p in forecasts.items():
    brier = np.mean((p - y) ** 2)
    logloss = -np.mean(y * np.log(p) + (1 - y) * np.log(1 - p))
    print(f"{name:30s} Brier = {brier:.5f}   skill = {1 - brier / ref:+.3f}   log loss = {logloss:.4f}")

Output, produced by running the code above when this page was built:

base rate = 0.0341
always the base rate           Brier = 0.03291   skill = +0.000   log loss = 0.1486
true probabilities             Brier = 0.03075   skill = +0.066   log loss = 0.1276
overconfident (too extreme)    Brier = 0.03549   skill = -0.078   log loss = 0.1421
always zero                    Brier = 0.03407   skill = -0.035   log loss = 0.4707

Every Brier score is small because the event is rare: predicting zero for everyone scores about the base rate. The skill score makes the differences readable. The two scores do not rank the forecasts alike: the overconfident forecast is worse than the base rate on the Brier score and better on the log loss, and the log loss gives by far its worst value to the forecast of zero.

Where it misleads

  • On rare events the raw Brier score is close to the base rate for any forecast. Reported without the reference, a value of 0.03 says nothing.
  • The log loss is dominated by a few confident errors. One prediction of 0.0001 for an event that occurs can outweigh thousands of good ones, so probabilities are usually clipped, and the clip level changes the score.
  • Both mix calibration and discrimination in one number. Two models with the same Brier score can fail in different ways; the decomposition of Murphy into reliability and resolution separates them.
  • A score computed on the training data rewards overfitting. It is read on held-out data, like every other measure.

For a continuous outcome the corresponding score is the CRPS, which reduces to the Brier score when the outcome has two values.

In our work

We report a proper score next to the ranking measures in every classification project, with the score of the base-rate forecast beside it as the reference.

References

  1. Brier, G. W. (1950). Verification of forecasts expressed in terms of probability. Monthly Weather Review, 78(1), 1-3. doi:10.1175/1520-0493(1950)078<0001:VOFEIT>2.0.CO;2
  2. Gneiting, T., Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association, 102(477), 359-378. doi:10.1198/016214506000001437
  3. Murphy, A. H. (1973). A new vector partition of the probability score. Journal of Applied Meteorology, 12(4), 595-600. doi:10.1175/1520-0450(1973)012<0595:ANVPOT>2.0.CO;2

Have a question like this one on your own data? Tell us what you need in a few lines.

Send us the brief

Related pages

  • Probability calibration: slope and interceptCalibration asks whether predicted probabilities match observed frequencies. Two numbers summarise it: the intercept, for the overall level, and the slope, for the spread. A slope below 1 means predictions that are too extreme.
  • CRPS: continuous ranked probability scoreThe CRPS scores a full predictive distribution with one number in the units of the data. For a point forecast it reduces to the absolute error, which makes probabilistic and point forecasts comparable.
  • AUC and the Gini coefficient in credit scoringThe AUC is the probability that a randomly chosen defaulter has a worse score than a randomly chosen good payer. The Gini coefficient rescales it: Gini = 2 AUC − 1. Both measure ranking, and both depend on the population scored.
All library pages