Skip to content
Calcrivo

Log Loss Calculator

Calculate average log loss (binary cross-entropy) across a set of predicted probabilities and true labels.

Inputs

Actual binary labels for each sample.

Model's predicted probability of class 1 for each sample, same order as labels.

Average Log Loss

0.267821

Total Loss (Sum)

1.339105

Number of Samples

5

Worst Single-Sample Loss

0.4308

Step by step

  1. Per-sample loss: −(y×ln(p) + (1−y)×ln(1−p))

    −(y × ln(p) + (1−y) × ln(1−p))

    = 0.1054, 0.2231, 0.4308, 0.2231, 0.3567

  2. Total loss: sum over all samples

    Σ [0.1054, 0.2231, 0.4308, 0.2231, 0.3567]

    = 1.339105

  3. Average log loss: total loss ÷ N

    1.339105 ÷ 5

    = 0.267821

How it works

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.

Formula

LogLoss = -(1/N) × sum(y_i × ln(p_i) + (1 - y_i) × ln(1 - p_i))

N
Number of samples
y_i
True binary label for sample i
p_i
Predicted probability of class 1 for sample i

Frequently Asked Questions

Why is log loss preferred over accuracy for evaluating classifiers?

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).

What is a 'good' log loss value?

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.

How does log loss punish a confident wrong prediction?

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.

You might also need