Sub topic 3
Calibration is not accuracy or AUC
This chapter assumes you know how to compute accuracy and ROC AUC, you can read scikit-learn code, and you know that a logistic regression outputs sigmoid(w·x + b). Earlier chapters defined a calibrated probability: among all cases where the model says 0.8, about 80% are positive. Here you will see why that property is independent of the two metrics most people use to judge a classifier.
Three questions a classifier can answer
A binary classifier that outputs a probability can be judged on three separate questions.
- Accuracy: after applying a threshold (usually 0.5), how often is the predicted label correct?
- Discrimination: does the model give higher scores to positives than to negatives? ROC AUC measures this. It equals the probability that a randomly chosen positive gets a higher score than a randomly chosen negative.
- Calibration: do the numeric values of the scores match observed frequencies?
Accuracy depends on the scores only through which side of the threshold they fall on. AUC depends only on the ordering of the scores. Neither one looks at whether 0.9 means 90%. Calibration is the only property of the three that depends on the actual values.
Why the metrics are blind to calibration
Take any strictly increasing function f and apply it to every score. The ordering of the cases does not change, so AUC does not change. If f maps the threshold to itself (for example f(0.5) = 0.5), every predicted label stays the same, so accuracy does not change either. The probabilities, however, can change a great deal.
The following script shows this. It trains a logistic regression, which is usually close to calibrated, then stretches and squeezes its log-odds with a multiplier k. The expression expit(k * logit(p)) is strictly increasing in p and maps 0.5 to 0.5, so it has exactly the property described above.
import numpy as np
from scipy.special import expit, logit
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, brier_score_loss, log_loss, roc_auc_score
from sklearn.model_selection import train_test_split
X, y = make_classification(
n_samples=20000, n_features=20, n_informative=5, random_state=0
)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.5, random_state=0
)
model = LogisticRegression(max_iter=1000).fit(X_train, y_train)
p = model.predict_proba(X_test)[:, 1]
z = logit(np.clip(p, 1e-12, 1 - 1e-12))
variants = [("original", 1.0), ("overconfident", 3.0), ("underconfident", 1 / 3)]
print(f"{'variant':<15}{'acc':>7}{'auc':>8}{'brier':>8}{'logloss':>9}")
for name, k in variants:
q = expit(k * z)
print(
f"{name:<15}"
f"{accuracy_score(y_test, q > 0.5):>7.3f}"
f"{roc_auc_score(y_test, q):>8.3f}"
f"{brier_score_loss(y_test, q):>8.3f}"
f"{log_loss(y_test, q):>9.3f}"
)Run it and compare the rows. The accuracy and AUC columns match across all three variants (AUC can differ in the last digit if a score saturates to exactly 0 or 1 and creates ties). The Brier score and log loss columns differ. The original row should have the lowest values, because logistic regression fitted by maximum likelihood is close to calibrated on data like this. The multiplier of 3 makes the model claim far more certainty than it has, and log loss punishes that heavily. The multiplier of 1/3 makes it timid, and both losses rise there too.
Every variant has the same accuracy and the same AUC, yet at most one of them has probabilities you could quote to a user.
The four combinations
A model can be good or bad at discrimination, and good or bad at calibration, independently.
| Discrimination | Calibration | Example |
|---|---|---|
| Good | Good | A well-regularized logistic regression on enough data |
| Good | Poor | A deep network trained long enough to drive training loss near zero, or a boosted-tree ensemble. Rankings are strong, but scores are too extreme or too compressed |
| Poor | Good | A model that predicts the base rate for everyone |
| Poor | Poor | A noisy model with arbitrary outputs |
The "poor discrimination, good calibration" row is worth a closer look. If 30% of cases are positive and a model outputs 0.30 for every case, then among all cases scored 0.30, exactly 30% are positive. It is perfectly calibrated and has an AUC of 0.5, because every score is tied. Calibration alone is not an achievement. A useful probability needs both properties.
The "good discrimination, poor calibration" row can be extreme. Suppose a model gives every positive case a score of 0.6 and every negative case a score of 0.4. It ranks perfectly (AUC 1.0) and is 100% accurate at a threshold of 0.5. But among cases scored 0.6, 100% are positive, not 60%. Anyone reading "0.6" as a probability would badly underestimate the risk.
What each metric tells you
The table below summarizes what each common metric is sensitive to.
| Metric | Depends on | Changes under a monotone rescaling of scores? |
|---|---|---|
| Accuracy at threshold t | Which side of t each score falls on | Only if the transform moves t |
| ROC AUC | Ranking of scores | No |
| Log loss | Actual probability values | Yes |
| Brier score | Actual probability values | Yes |
| Expected calibration error | Gap between probabilities and observed rates | Yes |
Log loss and Brier score are the interesting middle case. They are proper scoring rules, so they reward honest probabilities, but they do not measure calibration in isolation. The Brier score decomposes (the Murphy decomposition) into three terms: a reliability term that measures miscalibration, a resolution term that measures how much the forecasts separate cases with different outcomes, and an uncertainty term that depends only on the base rate. Brier = reliability − resolution + uncertainty. A single loss value therefore mixes calibration and discrimination. A model can improve its loss by getting better at ranking while its calibration stays the same or worsens. To isolate calibration, use a reliability diagram or a binned error measure, which later chapters cover.
Why this matters for the fix
This independence is also why post-hoc calibration works at all. Methods such as Platt scaling, isotonic regression and temperature scaling learn a monotone map from raw scores to probabilities. A strictly increasing map keeps the ranking, so it cannot hurt AUC. Temperature scaling keeps the predicted class as well, so it cannot change accuracy. The calibrator repairs the values and leaves the ranking alone.
There are two caveats.
- Isotonic regression is only non-decreasing. It maps many different raw scores to the same output value, which creates ties. Ties can lower AUC slightly, and they remove the ability to rank within a flat step. Later chapters return to this.
- A calibrator cannot add discrimination. If the base model ranks poorly, calibration yields honest but uninformative probabilities, like the constant 0.30 predictor above.
The practical rule follows from this. Evaluate ranking quality and calibration quality separately, and report both. Improve discrimination by changing the model or features. Improve calibration by adding a post-processing step fitted on data the base model did not train on.
Exercises
Exercise
A fraud model has an AUC of 0.97. A colleague says its output of 0.9 can be read as "90% chance of fraud". Explain why the AUC does not support that claim, and name one check that would.
Show answer
AUC depends only on how the scores rank positives against negatives. Any strictly increasing transform of the scores leaves it unchanged, so a model with AUC 0.97 can still output values that are systematically too high or too low. To test the claim, build a reliability diagram on held-out data (or compute log loss, Brier score or ECE) and check whether, among cases scored near 0.9, about 90% are actually fraud.
Exercise
A model predicts 0.2 for every case, and 20% of cases in the test set are positive. What are its calibration and its AUC? Would a calibrator improve it?
Show answer
It is perfectly calibrated, because the observed positive rate among cases scored 0.2 is 20%. Its AUC is 0.5, because all scores are tied and it ranks nothing. A calibrator cannot help, since the probabilities are already honest. The model needs better features or a better learning algorithm to gain discrimination.