This page is the exhaustive drill. The parent note 2.6.11 gave you the formulas. Here we throw every kind of input at those formulas — perfect predictions, catastrophic ones, the edge cases that produce 0 or ∞, the degenerate model, and an exam trap — and grind each one to a number.
Before any formula appears we re-anchor its meaning in one line, because the promise of this vault is: no symbol used before it is earned.
Recall Two symbols we lean on constantly
p^ ::: the probability your model announced for the event happening (a number between 0 and 1).
y ::: the truth, written as 1 if the event happened and 0 if it did not.
Log-loss for one sample ::: −logp^ when y=1, and −log(1−p^) when y=0 — "surprise at the truth".
Every log-loss / calibration problem is one of these case classes. The examples below each carry a tag like [Cell A] so you can see the whole space is covered.
Cell
Case class
What makes it special
Example
A
Confident & correct
p^ near the true label → loss near 0
Ex 1
B
Confident & wrong
p^ near the opposite of truth → loss explodes
Ex 2
C
Timid / uncertain (p^≈0.5)
moderate loss regardless of outcome
Ex 3
D
Degenerate input (p^=0 or 1)
log0=−∞: the clipping fix
Ex 4
E
Multi-class (one-hot)
only the true class term survives
Ex 5
F
Calibration: over- vs under-confident bins
ECE via reliability gap
Ex 6
G
Degenerate calibration (empty bin, perfect bin)
how ECE handles 0/0 and gap =0
Ex 7
H
Real-world word problem
translate a story → p^,y
Ex 8
I
Exam twist (accuracy vs log-loss disagree)
which model "wins"?
Ex 9
Two anchor pictures for the whole page:
The loss curves above are the single most important image on this page. Read the amber curve as "the penalty when the truth was y=1": it dives to 0 as your announced p^→1 (you were right and confident), and rockets toward +∞ as p^→0 (you were confidently wrong). The cyan curve is the mirror for y=0.
The reliability diagram above is the picture behind every calibration example: the diagonal is "confidence tells the truth"; a bar's height above/below the diagonal is its calibration gap.
When y=1 ::: use −logp^.
When y=0 ::: use −log(1−p^).
Recall Why does one confidently-wrong sample dominate a batch?
Because −log of a tiny number is huge (unbounded above) ::: while a correct confident sample only earns a penalty near 0 — the curve is steep on the wrong side, flat on the right side.
Recall Do empty calibration bins change ECE?
No ::: their weight ∣Bm∣/N=0 multiplies away any (undefined) gap.
Recall Can a lower-accuracy model have lower log-loss?
Yes (Ex 9) ::: log-loss rewards honest, informative probabilities; accuracy only checks the side of the 0.5 threshold.