Logistic log loss
Binary log loss is the negative natural log probability of the label that occurred.
On this page 7 sections
01A logistic prediction gives the probability p of label 1#
A logistic prediction gives the probability p of label 1. Log loss evaluates the probability assigned to the label that actually occurred.
For , loss is . For , it is . These natural logarithms give nats.
If the observed label is 0 while p is 0.8, the model assigned probability 0.2 to the observed label. Its loss is about 1.6094 nats.
Label , predicted . Given and , find log loss in nats.
Show answer and explanation
The observed-label probability is . Negate its natural log: nats.
02A closer look#
For independent labeled observations, their likelihoods multiply and their negative log-likelihoods add. A mean loss divides that sum by the number of observations.
Read whether a task asks for a total or an average. Do not take the negative log of an average probability; that changes the objective.
Labels: . Class 1 probabilities: . Their observed-label log probabilities are . Find mean log loss in nats.
Show answer and explanation
Negate and average: 0.8675/2=0.43375 nats.
03Classification accuracy discards confidence after thresholding#
Classification accuracy discards confidence after thresholding. Two models with the same accuracy can assign different probabilities to the realized labels.
Compare their actual log losses. Greater confidence in a wrong label produces a larger penalty.
Observed-label ln probabilities: A=; B=. Lower total log loss?
Show answer and explanation
Totals: A=0.7; B=0.6.
Choose p for label 1 or 1−p for label 0, negate its log, and distinguish total loss from mean loss.
- Compute binary negative log-likelihood for logistic predictions.
Sources & further reading
- [1]Jurafsky & Martin: Speech and Language Processing, Chapter4 §4.5 ↗Jurafsky & Martin · Article