A Loss Encodes What Counts as Error
A loss function turns a prediction and target into an optimization signal. Its choice expresses assumptions about noise, error cost, class structure, and what tradeoffs the model should make.
Three Common Losses
| Loss | Form | Typical use |
|---|---|---|
| Mean squared error | Regression when large residuals should receive quadratic weight; connected to Gaussian-noise likelihood. | |
| Mean absolute error | Regression requiring more robustness to large residuals; connected to Laplace-noise likelihood. | |
| Cross-entropy | Classification or next-token prediction with probabilistic targets. |
Squaring Changes the Influence of Residuals
Under MSE, a residual of 10 contributes 100 while a residual of 1 contributes 1, so large residuals can dominate the fit. MAE grows linearly and is less sensitive to extreme residuals, although it has a nondifferentiable point at zero and answers a different statistical question.
Cross-entropy rewards probability assigned to the observed class, but minimizing it does not guarantee calibrated probabilities. Calibration depends on data, model specification, regularization, distribution shift, and sometimes post-hoc methods such as temperature scaling.