| Part of a series on |
| Machine learning anddata mining |
|---|
Learning with humans |
Model diagnostics |
Inmachine learning,Platt scaling orPlatt calibration is a way of transforming the outputs of aclassification model into aprobability distribution over classes. The method was invented byJohn Platt in the context ofsupport vector machines,[1] replacing an earlier method byVapnik, but can be applied to other classification models.[2] Platt scaling works by fitting alogistic regression model to a classifier's scores.
Consider the problem ofbinary classification: for inputsx, we want to determine whether they belong to one of two classes, arbitrarily labeled+1 and−1. We assume that the classification problem will be solved by a real-valued functionf, by predicting a class labely = sign(f(x)).[a] For many problems, it is convenient to get a probability, i.e. a classification that not only gives an answer, but also a degree of certainty about the answer. Some classification models do not provide such a probability, or give poor probability estimates.

.
Platt scaling is an algorithm to solve the aforementioned problem. It produces probability estimates
i.e., alogistic transformation of the classifier outputf(x), whereA andB are twoscalar parameters that are learned by the algorithm. After scaling, values can be predicted as. If then the probability estimates are modified from to the original decision functiony = sign(f(x)).[3]
The parametersA andB are estimated using amaximum likelihood method that optimizes on the same training set as that for the original classifierf. To avoidoverfitting to this set, a held-outcalibration set orcross-validation can be used, but Platt additionally suggests transforming the labelsy to target probabilities
Here,N+ andN− are the number of positive and negative samples, respectively. This transformation follows by applyingBayes' rule to a model of out-of-sample data that has a uniform prior over the labels.[1] The constants 1 and 2, on the numerator and denominator respectively, are derived from the application ofLaplace smoothing.
Platt himself suggested using theLevenberg–Marquardt algorithm to optimize the parameters, but aNewton algorithm was later proposed that should be morenumerically stable.[4]
Platt scaling has been shown to be effective for SVMs as well as other types of classification models, includingboosted models and evennaive Bayes classifiers, which produce distorted probability distributions. It is particularly effective for max-margin methods such as SVMs and boosted trees, which show sigmoidal distortions in their predicted probabilities, but has less of an effect with well-calibrated models such aslogistic regression,multilayer perceptrons, andrandom forests.[2]
An alternative approach to probability calibration is to fit anisotonic regression model to an ill-calibrated probability model. This has been shown to work better than Platt scaling, in particular when enough training data is available.[2]
Platt scaling can also be applied to deep neural network classifiers. For image classification, such as CIFAR-100, small networks likeLeNet-5 have good calibration but low accuracy, and large networks likeResNet has high accuracy but is overconfident in predictions. A 2017 paper proposedtemperature scaling, which simply multiplies the output logits of a network by a constant before taking thesoftmax. During training, is set to 1. After training, is optimized on a held-out calibration set to minimize the calibration loss.[5]