The simulators have known truth. Real data do not, and the only available evidence is the labels. Listing 1.8 uses the 569-case breast-cancer data bundled with scikit-learn, which are the Wisconsin diagnostic data of Street, Wolberg and Mangasarian (1993) as distributed by the UCI repository (Dua and Graff, 2019). For each of 30 random splits, we train on 200 cases, calibrate on 150 and test on the remaining 219. Three classifiers are trained: standardized logistic regression, Gaussian naive Bayes, and a random forest of 100 trees. For each, the logit of the predicted probability is the score to be calibrated by Platt scaling and by isotonic regression.
The simulators have known truth. Real data do not, and the only available evidence is the labels. the companion book example uses the 569-case breast-cancer data bundled with scikit-learn, which are the Wisconsin diagnostic data of Street, Wolberg and Mangasarian (1993) as distributed by the UCI repository (Dua and Graff, 2019). For each of 30 random splits, we train on 200 cases, calibrate on 150 and test on the remaining 219. Three classifiers are trained: standardized logistic regression, Gaussian naive Bayes, and a random forest of 100 trees. For each, the logit of the predicted probability is the score to be calibrated by Platt scaling and by isotonic regression.
The results reflect the known tendencies of these learners and an inconvenient fact about small samples.
- Naive Bayes is the most overconfident and benefits most. Its log loss falls from 0.454 to 0.161 with Platt scaling and to 0.290 with isotonic regression, and its Brier score falls from 0.0588 to 0.0444 and 0.0466 respectively.
- Logistic regression is already well calibrated here, and calibration hurts the log loss (0.088 raw, 0.117 with Platt, 0.251 with isotonic) and slightly hurts the Brier score (0.0235, 0.0244, 0.0281). With only 150 calibration cases there is more to lose from estimating a map than to gain from correcting a small error. This is the small-sample effect of the companion book example, observed on real data.
- The random forest is in between: the Brier score is nearly unchanged (0.0378 raw, 0.0380 Platt, 0.0393 isotonic) and the log loss is slightly worse after calibration.
- Accuracy is essentially unaffected for every method: 0.971, 0.970 and 0.968 for logistic regression, and 0.936, 0.937 and 0.934 for naive Bayes. The thresholded decision at 0.5 barely changes, as it should for monotone maps.
- Isotonic log loss is higher than Platt’s for every model. Part of this is an artifact: isotonic outputs exact 0 or 1 at the ends, the log loss clips them at , and a single error then costs nats.
- ECE differs little between rows (0.0289 and 0.0287 for logistic raw and Platt) and should not be over-interpreted. With 219 test cases the estimator’s own noise (the companion book example) is of the same size as these differences. The Brier score and the log loss are the safer guides.
The conclusion is not that calibration is useless. It is that its benefit is concentrated in models that are visibly miscalibrated, and that a calibrator must be validated like any other fitted component, against held-out data with a proper score.
For multi-class problems the natural tool is temperature scaling on the logits. the companion book example applies it to the 1797-case digits data (the UCI optical recognition of handwritten digits data, Kaynak, 1995, as bundled with scikit-learn) with 500 training, 400 calibration and 897 test cases, averaged over 10 splits.
The fitted temperatures expose the character of each model. Naive Bayes is strongly overconfident () and temperature scaling cuts its NLL from 2.993 to 0.651 and its top-label ECE from 0.1580 to 0.0404. The logistic regression with weak regularization () is also overconfident (), with NLL falling from 0.357 to 0.177. The random forest is underconfident, and its fitted temperature is below 1 (): the NLL falls from 0.456 to 0.154 and the top-label ECE from 0.2700 to 0.0155, the largest ECE reduction of the three. The accuracy is identical before and after for each model (0.947, 0.833, 0.954). Remaining ECE values near 0.015 to 0.04 are partly the estimator’s noise floor for 897 test cases. The caveat of the companion book example applies here too.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI Under Uncertainty.
Companion article for Applied AI Under Uncertainty, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
