Log Loss (Cross-Entropy)
The standard loss and metric for probabilistic classifiers: it heavily punishes confident wrong answers and rewards well-calibrated probabilities.
Also cross-entropy loss · binary cross-entropy · categorical cross-entropy · negative log-likelihood · NLL
A quiz where you bet on your answers. Saying 'I'm 99% sure' and being wrong costs you a fortune. Saying '60% sure' and being wrong costs a little. You learn to be honest about how sure you are.
Where it fits
+All relationships as a list
Is a kind of / part of
Siblings
Used by
How it works
Accuracy only checks whether the top answer was right. Log loss also looks at how confident the model was.
For each example, take the probability the model gave to the correct class, , and compute :
| Probability on the right answer | Loss |
|---|---|
| 0.99 | 0.01 |
| 0.9 | 0.11 |
| 0.5 | 0.69 |
| 0.1 | 2.30 |
| 0.01 | 4.61 |
A confident wrong answer is punished far more than a hesitant one. The best strategy is to be honest: say 70% when you are right 70% of the time.
It is the default loss function for classification: logistic regression, image classifiers and language models all minimize it. For language models, averaging it over every token and taking the exponent gives perplexity.
The math
For examples with true classes and predicted distributions ,
This is the negative log-likelihood of the labels, so minimizing it is maximum likelihood estimation. See probability basics.
Everyday use cases
- Case 01
Training classifiers
Logistic regression, image classifiers and LLMs are all trained by minimizing cross-entropy.
- Case 02
Forecasting competitions
Rain forecasts and prediction markets are scored with log loss so forecasters cannot fake confidence.
Strengths, weaknesses and when to use it
Strengths
- Rewards calibrated probabilities, not just correct labels.
- Smooth and well suited to gradient descent.
Weaknesses
- A single confident mistake can dominate the average; very sensitive to label noise.
- Hard to interpret on its own; compare against a baseline.
When to use itAs the training loss for classification and as an evaluation metric when probability quality matters.
Compare with
Check yourself
- Q01
The true class is A. Which prediction has the higher log loss?
Show answer
C: P(A) = 0.01
- Q02
How is perplexity related to cross-entropy?
Show answer
A: It is the exponent of the average cross-entropy