Scoring probabilities: log loss and Brier
A prediction is more than a yes or no. Proper scoring rules reward honest probabilities, and punish confident mistakes. Learn what each one measures.
What runs in CodeSplash
- Calibration of predicted risks Verified in Python and R
- Decision tree (CART) Verified in Python and R
- Discriminant analysis (LDA / QDA) Verified in Python and R
You will be able to
- Compute log loss and the Brier score for a row
- Explain what makes a scoring rule proper
- Read the Brier decomposition into reliability, resolution and uncertainty
Read first
The price of being wrong
ReadBrier score: mean squared difference between probability and outcome. Log loss: mean of the negative log of the probability you gave to what happened.
Both are lower when better. Unlike accuracy, they see the difference between 51% and 99%.
Confident and wrong
PredictPredict first
The event happens. Model A gave it 40%, and model B gave it 1%. How much larger is B's log-loss penalty than A's on this row?
Reveal
About five times: against . And there's no ceiling: at 0.1% it's about . This is why a single tree, whose leaves can say exactly 0 or 1, does so badly on log loss. On penguins it gets 0.429, and LDA gets 0.0242.
Proper means honesty pays
ReadA scoring rule is properProper scoring ruleA score whose expected value is best when you report your true probability. Log loss and Brier are proper. if your expected score is best when you report what you actually believe. Log loss and Brier are proper.
Accuracy isn't: it only sees which side of 50% you're on, so there's no reward for honest probabilities. If the probabilities will drive decisions, rank your models by a proper score, not by accuracy.
See the score move
ExploreRaise Overconfidence to make the model too extreme, then lower it to hedge. Read Brier, ECE and Calibration slope. Now look at AUC. Does it move?
HExplorable · Calibration and reliability
When a model says 80%, does the event happen 80% of the time?
If you make the model more overconfident, what happens to its AUC?
Above 1 the model is too extreme; below 1 it hedges. At 1 it is perfectly calibrated.
| Brier | ECE | Calibration slope | AUC |
|---|---|---|---|
| 0.175 | 0.087 | 0.50 | 0.835 |
Commit your prediction above to see the result
Make your prediction to see the result.
Stretching probabilities doesn't change their order, so AUC stays still while the proper scores punish the distortion.
Three parts of a Brier score
ReadThe app's Calibration table on a binary run splits the Brier score:
- Reliability: how far probabilities are from observed shares. Lower is better.
- Resolution: how much predictions separate rows. Higher is better.
- Uncertainty: set by the base rate alone.
For a logistic-style score on Pima, the Brier score is 0.144, and gives 0.350: a skill score, like .
Which one?
ReflectLog loss is much harsher on confident mistakes, so it fits when you truly can't afford them, or as the training loss. It's the automatic primary metric for multiclass tasks.
Brier is bounded and easier to explain, and it's more forgiving of a stray extreme.
A model can win on one and lose on the other, usually because of a few confident misses. If that happened to you, whose decision would those rows change?
Check your understanding
CheckpointCheck yourself
A model gives 70% to an event that happens. What is the Brier penalty on this row?
Show the answer
Answer: 0.09
.
Check yourself
With a 50% base rate, what Brier score does the constant prediction 50% get?
Show the answer
Answer: 0.25
for every row. A useful probabilistic model must beat that. In general the no-skill value is .
Check yourself
Why prefer a proper score over accuracy for choosing between probability models?
Show the answer
Answer: b
Accuracy treats 51% and 99% the same. Proper scores reward getting the probability itself right.
On your run
In the appPick Log loss or Brier score (binary) as the Primary metric in Setup to rank by probability quality. Overview reports both on any binary run, and Evaluation has the Calibration table.
import numpy as np
y = np.array([1, 0, 1, 1, 0])
for name, p in [("hedged", np.array([0.7, 0.3, 0.6, 0.8, 0.4])),
("overconfident", np.array([0.99, 0.01, 0.99, 0.99, 0.99]))]:
brier = np.mean((p - y) ** 2)
logloss = -np.mean(y * np.log(p) + (1 - y) * np.log(1 - p))
print(name, round(brier, 3), round(logloss, 3))y <- c(1, 0, 1, 1, 0)
score <- function(p) c(brier = mean((p - y)^2), logloss = -mean(y * log(p) + (1 - y) * log(1 - p)))
round(rbind(hedged = score(c(0.7, 0.3, 0.6, 0.8, 0.4)),
overconfident = score(c(0.99, 0.01, 0.99, 0.99, 0.99))), 3)Recap
Recap- Log loss and Brier score the probability, not only the side of 50%.
- Proper scores reward honesty, and log loss punishes confident mistakes hardest.
- Brier splits into reliability, resolution and uncertainty, and a proper score can move while AUC doesn't.
Concepts in this lesson