All problems
EasyMetricsv2026-06-27

Metrics ยท Easy

Log Loss

Evaluate probabilistic predictions with numerical stability.

Task

Implement logloss(labels: list[int], probabilities: list[float]) -> float. Compute the mean negative log-likelihood of binary labels under predicted probabilities.

Requirements

  • Clip every probability to [1e-15, 1 - 1e-15] before taking logarithms.
  • Use the natural logarithm.
  • Return 0.0 for empty inputs.
  • Inputs have equal length and labels are binary.

Example

labels = [1, 0]
probabilities = [0.9, 0.2]

logloss(labels, probabilities)
# 0.1642520335
solution.pySign in to save
Public tests run locally in your browser.
Run your code to see public test results.