Library · Credit scoring

Probability calibration: slope and intercept

Calibration asks whether predicted probabilities match observed frequencies. Two numbers summarise it: the intercept, for the overall level, and the slope, for the spread. A slope below 1 means predictions that are too extreme.

By , published

Definition

Fit a logistic regression of the observed outcome on the logit of the predicted probability p:

logit( P(y = 1) ) = a + b × logit( p )

A perfectly calibrated model gives a = 0 and b = 1. A slope below 1 means the model is overconfident: its high probabilities are too high and its low ones too low, the usual sign of overfitting. An intercept away from 0, at a slope of 1, means the average level is wrong, for instance after a change in the default rate. Platt scaling uses the same regression as a correction: the fitted a and b, estimated on data held out, are applied to new predictions.

Worked example

A model produces probabilities that are too extreme. We measure its calibration on a calibration sample, apply Platt scaling, and check the result on a separate test sample.

import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score

rng = np.random.default_rng(24)
def sample(n):
    z = rng.normal(-2.2, 1.0, n)                       # true log odds
    y = (rng.random(n) < 1 / (1 + np.exp(-z))).astype(int)
    p = 1 / (1 + np.exp(-(1.6 * z + 1.1)))             # the model: right ranking, too extreme
    return p, y

logit = lambda p: np.log(p / (1 - p)).reshape(-1, 1)
def slope_intercept(p, y):
    m = LogisticRegression(C=1e6).fit(logit(p), y)
    return m.intercept_[0], m.coef_[0, 0], m

p_cal, y_cal = sample(5000); p_test, y_test = sample(20000)
a, b, platt = slope_intercept(p_cal, y_cal)
p_fixed = platt.predict_proba(logit(p_test))[:, 1]

for name, p in [("raw model", p_test), ("after Platt scaling", p_fixed)]:
    a2, b2, _ = slope_intercept(p, y_test)
    top = p >= np.quantile(p, 0.9)
    print(f"{name:20s} slope = {b2:.2f}  intercept = {a2:+.2f}  AUC = {roc_auc_score(y_test, p):.3f}  "
          f"riskiest tenth: predicted {p[top].mean():.3f}, observed {y_test[top].mean():.3f}")

Output, produced by running the code above when this page was built:

raw model            slope = 0.63  intercept = -0.68  AUC = 0.750  riskiest tenth: predicted 0.584, observed 0.401
after Platt scaling  slope = 1.02  intercept = +0.04  AUC = 0.750  riskiest tenth: predicted 0.390, observed 0.401

The raw model predicts far more defaults in its riskiest tenth than actually occur. After the correction the slope is close to 1 and predicted and observed rates agree. The AUC is identical before and after: calibration and ranking are separate properties.

Where it misleads

  • Slope and intercept are averages over the score range. A model can have a slope of 1 and be miscalibrated in one segment or one band, so calibration is also read by band and by segment.
  • The correction must be fitted on data the model was not trained on. Fitted on the training data, it hides the overfitting it was meant to reveal.
  • Platt scaling assumes the distortion is a straight line on the logit scale. Isotonic regression drops that assumption and needs more data: on small samples it overfits, as Niculescu-Mizil and Caruana measured.
  • Calibration drifts with the default rate. A model calibrated in a good year over-predicts or under-predicts in the next, with an unchanged Gini.

Calibration is scored with the Brier score or the log loss, which reward both calibration and sharpness.

In our work

In our credit model validation report the boosting model had a calibration slope of 1.00 on the sealed holdout, against 1.14 for the scorecard benchmark, and calibration was checked by segment as well.

References

  1. Niculescu-Mizil, A., Caruana, R. (2005). Predicting good probabilities with supervised learning. Proceedings of the 22nd International Conference on Machine Learning, 625-632. doi:10.1145/1102351.1102430
  2. Van Calster, B., McLernon, D. J., van Smeden, M., Wynants, L., Steyerberg, E. W. (2019). Calibration: the Achilles heel of predictive analytics. BMC Medicine, 17, 230. doi:10.1186/s12916-019-1466-7
  3. scikit-learn developers (2026). Probability calibration. scikit-learn user guide. scikit-learn.org/stable/modules/calibration.html

Have a question like this one on your own data? Tell us what you need in a few lines.

Send us the brief

Related pages

  • Brier score and log lossThe Brier score and the log loss both score predicted probabilities against what happened, and both are proper: the best expected score goes to the true probability. They differ in how hard they punish a confident mistake.
  • AUC and the Gini coefficient in credit scoringThe AUC is the probability that a randomly chosen defaulter has a worse score than a randomly chosen good payer. The Gini coefficient rescales it: Gini = 2 AUC − 1. Both measure ranking, and both depend on the population scored.
  • Split conformal predictionConformal prediction wraps any model. It measures the errors on data set aside, and uses their quantile as the half-width of the prediction interval. The average coverage is guaranteed without assuming a distribution, under one condition.
All library pages