Open Agent School · Public worked example

Log loss: meaning and example

Welcome! Take one idea with you today.

Log loss penalizes a probability forecast according to how little probability it assigned to the observed outcome. Binary log loss evaluates two-outcome forecasts and averages the penalty over examples.

Picture it: A ticket really needs escalation, so its label is 1. A model assigns escalation probability 0.25. Its natural-log loss is -ln(0.25), about 1.386 nats. A probability of 0.75 for that same observed outcome would give about 0.288 nats.

What is easy to mix up?

A probability of 0.6 for the observed positive class gives a correct decision at threshold 0.5 but still positive loss. Zero is reached only when the observed event receives probability 1 under the limiting definition.

Teaching example by Open Agent School. Source: scikit-learn: Model Evaluation.