Log loss calculator

A confident mistake should leave a visible mark in your forecast record. Score resolved Yes/No probabilities, inspect each loss and compare a baseline on the same outcomes.

Score the probabilities you recorded.

One resolved binary forecast per row. Enter probability of Yes as a percent, followed by 1 for Yes or 0 for No. These example records are fictional.

Clipped mode limits probabilities to [10⁻¹⁵, 1 − 10⁻¹⁵] before scoring. It applies the same rule to your baseline. This fixed threshold can differ from a library’s dtype-based clipping.

Mean forecast log loss
0.949674
Mean baseline log loss
0.693147
Baseline loss minus forecast loss
-0.256526
Records scored
4

Lower mean loss is better on these records. A positive finite difference favors your forecasts over the chosen baseline; a negative difference favors the baseline. This is not a profit calculation.

Each entered forecast and its constant-baseline comparison · natural-log units (nats)
LineYes forecastOutcomeForecast lossBaseline loss
170%Yes0.3566750.693147
220%No0.2231440.693147
390%No2.3025850.693147
440%Yes0.9162910.693147

Rows are equally weighted. This tool calculates in the page and does not validate market resolutions, estimate uncertainty, or establish that repeated forecasts are independent.

How to calculate log loss

For a recorded Yes probability p and an observed outcome y of 1 or 0, binary loss is −[y ln(p) + (1 − y) ln(1 − p)]. When Yes happens, score −ln(p); when No happens, score −ln(1 − p). Lower is better. The mean averages these losses across all supplied records.

The official scikit-learn reference documents the binary formula, natural logarithms and mean normalization. Source reviewed October 12, 2026.

One confident error can change the mean

The fictional rows 70,1; 20,0; 90,0; 40,1 produce losses about 0.356675, 0.223144, 2.302585 and 0.916291. The mean is approximately 0.949674 nats. A constant 50% baseline scores about 0.693147 on every binary outcome, so that baseline does better on these four records.

The 90% forecast for an outcome that did not happen contributes the largest loss. This is why inspecting row results matters. Changing the forecast to 99% makes that one loss about 4.605170; changing it to 100% makes exact loss infinite. These examples do not measure Alphascope, Kalshi or Polymarket performance.

Exact boundaries and explicit clipping

A correct certain forecast has zero exact loss; a wrong certain forecast has infinite exact loss. This calculator evaluates the observed branch directly, avoiding the undefined expression 0 × ln(0). Clipped mode instead bounds probabilities to [10⁻¹⁵, 1 − 10⁻¹⁵]. The finite cap is a numerical convention, not evidence that an impossible prediction was reasonable.

The reference library uses dtype machine precision for clipping. Record the rule used before comparing boundary-heavy results from different tools. Do not silently replace infinite rows, delete them or switch thresholds after seeing the score.

How to calculate log loss in Python

This standard-library example reproduces the four interior-probability rows. It handles exact boundary cases without silently clipping:

from math import log, log1p, inf

records = [(0.70, 1), (0.20, 0), (0.90, 0), (0.40, 1)]

def binary_loss(p, y):
    if not 0 <= p <= 1 or y not in (0, 1):
        raise ValueError("Use probability 0..1 and outcome 0 or 1")
    if (p == 0 and y == 1) or (p == 1 and y == 0):
        return inf
    return -log(p) if y == 1 else -log1p(-p)

losses = [binary_loss(p, y) for p, y in records]
print(sum(losses) / len(losses))  # about 0.949674

Choose the baseline before judging the result

The baseline input applies one chosen probability to every supplied outcome. It defaults to 50% as an illustrative reference, not a claim that 50% is the right baseline for every market. Choose a defensible probability from information available before resolution and document that choice. Fitting a baseline to the scored outcomes gives it hindsight information.

Preserve forecast timestamps, market IDs, outcome definitions and your sampling rule. Compare the same resolved records at the same forecast horizon; keep losing forecasts and describe exclusions. Many observations of one event do not establish a large independent sample.

Inspect a complementary view with the calibration calculator and reliability diagram.

Log loss, Brier score and trading results

The Brier score calculator uses squared probability error. Log loss is unbounded at wrong certainty, so two sets can rank differently under the two metrics. Neither mean alone isolates calibration or proves a forecasting edge.

For prediction-market decisions, keep forecast evaluation separate from executable quotes, fees and liquidity. Use the expected-value calculator for assumed probability versus purchase cost, and read how to evaluate Polymarket accuracy for a careful performance comparison.

Frequently asked questions

What is log loss?

Binary log loss is the negative natural logarithm of the probability assigned to the observed outcome. Average the row losses to score a set of equally weighted forecasts.

What happens to a wrong 100% prediction?

Exact scoring assigns infinite loss to an outcome given zero probability. The optional clipped mode applies a declared threshold of 10^-15 to make boundary losses finite.

Does a lower log loss mean profitable trades?

No. Forecast scoring does not include executable prices, fees, liquidity or position sizing. Compare scores on the same records and analyze trading economics separately.

Does this match scikit-learn exactly?

Interior binary probabilities use the same natural-log formula. Boundary results can differ because this tool offers exact scoring or fixed 10^-15 clipping, while scikit-learn clips by its probability array's machine precision.