Quant Memo
Core

Platt Scaling

Platt scaling fixes miscalibrated classifier scores by fitting a simple logistic regression from the raw output onto true outcomes, turning scores that rank examples correctly but don't behave like real probabilities into ones that do.

Prerequisites: Probability Calibration, The Confusion Matrix and Classification Metrics

Many classifiers — support vector machines, random forests, gradient-boosted trees — produce a score that correctly ranks examples from least to most likely to belong to a class, but that score is not a genuine probability. A model might assign a score of 0.9 to a group of examples where the true positive rate among them is actually only 60%. The ranking is fine, but the number itself is misleading if used as a probability — for sizing a bet, computing expected value, or setting a risk-weighted threshold. Platt scaling is a simple, cheap fix for exactly this problem.

The fix: fit a logistic curve on top of the raw score

Platt scaling takes the model's raw output score ss (which could be a distance from a decision boundary, a fraction of tree votes, or any uncalibrated score) and fits a single logistic regression with just two parameters, AA and BB, mapping that score onto calibrated probability:

P(y=1s)=11+eAs+B.P(y=1 \mid s) = \frac{1}{1 + e^{As + B}} .

In plain English: rather than retraining or modifying the original classifier at all, you take its raw scores on a held-out calibration set, along with the true labels, and fit a small logistic regression that learns exactly how the raw score should be stretched, shifted, and squashed through an S-curve to line up with true observed frequencies. It's a post-processing step — a "correction lens" placed over an already-trained model's output — not a change to the model itself.

Worked example: recalibrating an overconfident score

Suppose a boosted classifier assigns a raw score around 0.85 to a batch of 200 held-out examples, but checking the actual labels shows only 130 of those 200 (65%) are truly positive — the model is systematically overconfident at that score level. Fitting Platt scaling on a calibration set spanning many such batches learns parameters AA and BB such that a raw score of 0.85 now outputs a calibrated probability close to 0.65, while a raw score of 0.3 (already accurate at 30%) is left close to unchanged. Because it's a monotonic transformation, examples keep the same relative ranking — Platt scaling never changes which example is more or less likely, only whether the attached number behaves like a genuine probability.

When Platt scaling is (and isn't) the right tool

Platt scaling's strength is its simplicity — two parameters, fit quickly on a modest calibration set — which makes it well suited to models whose miscalibration follows roughly the S-shaped (sigmoidal) pattern typical of margin-based classifiers like SVMs. It's less well suited to models whose miscalibration is more irregular or non-monotonic across the score range, where a more flexible method like isotonic regression (which fits an arbitrary non-decreasing step function rather than a fixed logistic shape) can capture patterns Platt scaling's rigid S-curve cannot. The tradeoff is the usual bias-variance one: Platt scaling's simplicity makes it more data-efficient and reliable with a small calibration set, while isotonic regression is more flexible but needs more calibration data to avoid overfitting the correction itself.

Function explorer
-221.1
x = 1.00f(x) = 0.731

The S-shaped curve in the explorer above is literally the function Platt scaling fits — adjust its parameters and notice how the same raw score can be mapped to very different calibrated probabilities depending on the curve's steepness and midpoint.

What this means in practice

Any time a classifier's output is used for something that depends on the actual probability value, not just the ranking — expected-value position sizing, a Kelly-criterion-style bet size, or blending scores from several different model types with different native scales — check calibration first with a reliability diagram, and apply Platt scaling (or isotonic regression) using a calibration set that was never used for training or model selection. Skipping this step is a common source of silently miscalibrated risk sizing in production models.

Platt scaling fits a simple two-parameter logistic regression to map a classifier's raw, potentially miscalibrated scores onto genuine probabilities, using a held-out calibration set of raw scores and true labels. It preserves the model's ranking of examples exactly while fixing the numeric meaning of the score, and is best suited to roughly S-shaped miscalibration patterns; more irregular miscalibration may need the more flexible isotonic regression instead.

Don't fit Platt scaling on the same data used to train the original classifier — the raw scores on training data are typically overconfident in a way that doesn't reflect true out-of-sample miscalibration, so the correction learned would itself be miscalibrated. Always use a separate, held-out calibration set.

Related concepts

Practice in interviews

Further reading

  • Platt, 'Probabilistic Outputs for Support Vector Machines' (1999)
ShareTwitterLinkedIn