Calculate logarithmic loss for probabilistic classification predictions.
Log loss is the dataset-level average of binary cross-entropy across N samples: LogLoss = (1/N)·Σ[y·ln(p) + (1−y)·ln(1−p)], negated. It's a standard classifier evaluation metric that, unlike accuracy, directly rewards well-calibrated probabilities — a model that confidently predicts the wrong class is penalized far more heavily than one that is uncertain, since ln(p) approaches −∞ as p approaches 0. Log loss is the metric minimized during training of most probabilistic binary classifiers, and is commonly reported for competition leaderboards (e.g. Kaggle) because it evaluates the quality of predicted probabilities, not just the final thresholded class.
LogLoss = -(1/N) × sum(y_i × ln(p_i) + (1 - y_i) × ln(1 - p_i))
Accuracy only looks at whether the final thresholded prediction was right or wrong, ignoring how confident the model was — log loss directly penalizes overconfident wrong predictions and rewards well-calibrated probability estimates, which matters when probabilities themselves are used downstream (e.g. for ranking or risk scoring).
It's problem-dependent, but as a reference, a model that always predicts p=0.5 achieves a log loss of ln(2) ≈ 0.693 regardless of the true labels — a well-performing model should score meaningfully below this baseline, with values closer to 0 indicating better calibrated, more confident correct predictions.
If a sample's true label is 1 but the model predicts p=0.01, the loss for that sample is −ln(0.01) ≈ 4.6 — dramatically higher than the ≈0.69 loss from an uncertain p=0.5 prediction, illustrating why log loss discourages overconfidence on samples the model might get wrong.