A classifier that outputs probabilities should be scored on those probabilities, not only on the hard label. Log loss punishes confident wrong answers heavily: predicting 0.99 for a true negative costs far more than predicting 0.6. It is the average negative log-likelihood of the true labels under the predicted probabilities.
Implement log_loss(y_true, y_prob, eps=1e-15) for binary labels, where y_prob is the predicted probability of class 1.
[eps, 1 - eps] so log(0) never occurs.y_true values must be 0 or 1, and y_prob values must lie in [0, 1]. Otherwise raise ValueError.Open one at a time. Each gives away a little more than the last.
np.clip the probabilities before taking logs.
Write the per-row loss as -(y * log(p) + (1 - y) * log(1 - p)), then take the mean.
No results yet
Run your code to check it against the examples, or submit to run every test.