T

Temperature Scaling

TS

Temperature scaling is a technique used to adjust the confidence of model predictions.

Temperature scaling is a post-processing technique applied to the outputs of machine learning models, particularly in classification tasks. It is primarily used to calibrate the probabilities produced by models, ensuring they reflect the true likelihoods of the predicted classes. This method is especially useful when a model’s predictions are overly confident or miscalibrated, which can lead to suboptimal decision-making.

The concept of temperature scaling derives from statistical thermodynamics. In this context, ‘temperature’ is a parameter that controls the smoothness of the softmax function, which converts raw model outputs (logits) into probabilities. By adjusting this temperature parameter, we can either sharpen or soften the distribution of predicted probabilities.

When the temperature is less than one (T < 1), the softmax function amplifies the differences between the logits, making the model more confident in its predictions. Conversely, when the temperature is greater than one (T > 1), the softmax function flattens the logits, resulting in more uniform probabilities and reduced confidence. The goal is to find an optimal temperature that minimizes the difference between the predicted probabilities and the true class frequencies.

To implement temperature scaling, one typically performs a calibration step on a separate validation dataset. This involves finding the best temperature value through a simple grid search or optimization techniques that minimize a loss function, such as the negative log-likelihood. The calibrated model can then provide better-calibrated predictions, improving performance in applications where understanding uncertainty is crucial, such as in medical diagnoses or financial forecasting.

Ctrl + /