Evaluation & Metrics

log loss

/ LOG loss /

Accuracy only asks whether a model got the answer right. Log loss asks something deeper: how confident was it, and was that confidence deserved? A model that says "90 percent chance of rain" and is then right should score better than one that hedges at "55 percent." Log loss rewards being both correct and appropriately sure, and it punishes confident mistakes brutally.

Here's the mechanism. For each example, log loss looks at the probability the model assigned to the answer that actually happened, and adds a penalty equal to the negative logarithm of that probability. Assign 0.99 to the true outcome and the penalty is tiny; assign 0.01 to it and the penalty is enormous. The average of these penalties is the log loss — lower is better, and a perfect, perfectly-confident model would score 0.

Log loss is the natural scoring rule whenever you care about probabilities, not just labels — weather, medical risk, ad clicks. Its sharpest feature is also its sharpest danger: because the penalty for being confidently wrong shoots toward infinity, a single arrogant, dead-wrong prediction (say 0.999 on something that didn't happen) can wreck your whole score. That's exactly why it pushes models toward honest, well-calibrated probabilities rather than reckless overconfidence.

Two forecasts for a day it does rain. Model A said 0.9 → penalty −log(0.9) ≈ 0.11. Model B said 0.1 → penalty −log(0.1) ≈ 2.30. Both could be "wrong" or "right" under a 0.5 cutoff, but log loss separates the cautiously-right from the confidently-wrong by a factor of twenty.

Log loss grades confidence, not just the final yes/no call.

Log loss only makes sense if the model's outputs are genuine probabilities, not arbitrary scores. Many models output numbers that look like probabilities but aren't well-calibrated; check calibration before trusting a log loss, and never assign exactly 0 or 1, since a confident error there sends the loss to infinity.

Also called
对数损失對數損失cross-entropy loss交叉熵损失logistic lossnegative log-likelihood