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.

Log loss vs accuracy: three forecasts with the same hit rate

Accuracy converts probabilities into decisions at a chosen threshold. Log loss evaluates the probability assigned to what actually happened. The distinction matters when evaluating a prediction-market forecast: a 51% and a 99% Yes forecast can produce the same predicted label while expressing very different confidence.

Here is an original four-event example. The resolved outcomes are Yes, Yes, Yes, No. Use a fixed 50% decision threshold, classifying 50% or higher as Yes. These probabilities are invented, with no claim about Alphascope or any venue’s forecasting performance.

Equal event weights, natural logarithms, exact scoring
Forecast setYes probabilitiesAccuracyMean log lossBinary Brier loss
A60%, 60%, 60%, 60%75%0.6121920.210000
B99%, 99%, 99%, 99%75%1.1588300.245100
C90%, 90%, 49%, 10%75%0.2573580.072525

All three sets get three threshold decisions right. B’s single wrong 99% forecast incurs a loss of about 4.605170, enough to outweigh three very small losses. C assigns 49% to the third Yes outcome and gets that decision wrong, but its moderate confidence limits the penalty. Its other forecasts assign 90% to what happens. C therefore has the smallest mean loss on this particular sample.

Reproduce these rows in the calculator using percentages. For C, enter 90,1; 90,1; 49,1; 10,0 with each pair on a separate line. The downloadable standard-library Python comparison instead expects probabilities from 0 to 1. It checks the table, reversed row order, outcome relabeling, exact boundaries and invalid inputs. It makes no network requests.

What is a good log loss?

There is no universal cutoff. A preselected constant 50% forecast scores about 0.693147 nats per event. In the example above, A and C beat that reference and B does worse. That is a descriptive comparison of four records, not proof of statistical significance or a durable edge.

Class balance changes the difficulty of the task. A constant forecast can achieve a small loss on an easy, imbalanced sample. Compare a defensible baseline on the same outcomes and horizons, selected using information available before those outcomes. Keep the sign convention clear: this page reports negative log probability as a loss, so lower is better. Some scoring-rule papers report log probability as a reward, so higher is better.

For example, fitting a constant 75% forecast to these four outcomes after resolution gives a mean loss of about 0.562335. That is an in-sample optimum for this particular constant model, not an independently forecast baseline. Reporting it as though someone had known the event frequency in advance would introduce hindsight. Our look-ahead bias guide explains why the information timeline matters.

Why logarithmic scoring is strictly proper

A strictly proper score rewards the true probability in expectation. This is an expectation over possible outcomes, not a promise that an honest probability wins on every realized event. The Gneiting and Raftery scoring-rule paper describes the logarithmic score and its properness. Here we use the negative-loss convention.

For a hypothetical true Yes probability q and a reported probability p strictly between zero and one, expected binary loss is:

E[L] = −q ln(p) − (1 − q) ln(1 − p)
dE[L]/dp = (p − q) / (p(1 − p))

For an interior q, the derivative is negative when p is below q and positive when p is above q, giving a unique minimum at p = q. If q is 70%, reporting 70% has expected loss about 0.610864; reporting 50% has expected loss about 0.693147. The difference is about 0.082283 nats per event under those stated assumptions.

This argument concerns exact probabilities and expected scoring. A finite sample can rank forecasts differently by chance. Clipping changes the numerical scoring rule at the boundaries; record its threshold instead of presenting clipped output as identical to exact scoring. Also preserve unresolved or disputed outcomes separately rather than inventing binary labels.

Comparison and downloadable worksheet checked . Use walk-forward analysis to design a time-respecting evaluation. A small score remains separate from executable market prices, transaction costs and trading returns.

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.