Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.How you score mistakes changes what you learn
A loss function is a scoring rule for mistakes. Counting wrong answers (0-1 loss) is natural but hard to optimize, because it jumps rather than slides. Squaring errors punishes big misses heavily, so one crazy measurement can wreck a fit. Using absolute errors is calmer about outliers. Choosing the loss is choosing what “good” means, and it changes the model you get.
Sensor data from robots and spacecraft contains glitches, dropouts and outliers. Robust losses (Huber, L1) keep estimators and learned models from being hijacked by them. Classification losses shape calibration, which matters when a perception system’s confidence feeds a planner. Quantile losses give prediction intervals for safety margins.
- 1. Counting the number of wrong predictions is the…
- 2. Which loss is most affected by one huge outlier?
- 3. Why not just minimize the 0-1 loss directly?
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.Classification losses (labels ±1, score f, margin m = y f)
| Loss | ℓ(m) | Used by |
|---|---|---|
| 0-1 | 1[m ≤ 0] | the target |
| hinge | max(0, 1 − m) | support vector machines |
| logistic | ln(1 + e^(−m)) | logistic regression, neural nets (cross-entropy) |
| exponential | e^(−m) | AdaBoost |
| squared | (1 − m)² | least-squares classification |
All the surrogates are convex and (suitably scaled) upper-bound the 0-1 loss, so driving them down drives errors down.
Regression losses (residual r = y − f)
- Squared r²: its minimizer is the conditional mean.
- Absolute |r|: its minimizer is the conditional median.
- Huber: r²/2 for |r| ≤ δ, linear beyond. It behaves like squared loss near zero and like L1 far out.
- Pinball (quantile): τr for r ≥ 0 and (τ − 1)r otherwise. Its minimizer is the conditional τ-quantile.
- 1. Hinge loss at margin 0.5:
- 2. Minimizing absolute error estimates the…
- 3. Which loss trains AdaBoost?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.What each surrogate estimates
At a point with , the conditional risk is . Its minimizer is:
- logistic: , the log-odds, so σ(f*) = η gives calibrated probabilities;
- exponential: ;
- squared: ;
- hinge: , only the decision, not the probability.
All have the sign of the Bayes rule: they are classification-calibrated. Bartlett, Jordan and McAuliffe (2006) show that minimizing such a surrogate’s risk drives the 0-1 excess risk to zero.
Robustness
The gradient of the loss is the “pull” a point exerts on the fit: for squared loss (unbounded) and for L1 (bounded). An estimator’s breakdown point is the fraction of corrupted data it tolerates before it can be dragged arbitrarily: 0 for least squares, up to 50% for L1-type estimates of location (Huber and Ronchetti, 2009).
Proper scoring rules
For probabilistic predictions, log loss and the Brier score (squared error on probabilities) are proper: the expected score is minimized by reporting the true probability. That’s why cross-entropy training yields calibrated models in the large-data limit.
- 1. The logistic loss minimizer at η is…
- 2. Hinge loss's minimizer gives you…
- 3. Breakdown point of least squares:
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Deriving the logistic minimizer
Set . Since , this gives , i.e. . ∎
Hinge
For , the conditional risk is , which is linear in f. It is minimized at the endpoint . ∎
Absolute loss ↔ median
, which is zero where half the mass lies on each side. ∎ Similarly, pinball loss is minimized where .
Exercise 3.1: the exponential loss’s minimum value
At , the conditional risk is . For η = 0.7 that is 0.917.
- 1. Pinball loss at level τ is minimized by the…
- 2. σ(f) = η solves the first-order condition for…
- 3. Minimal expected exponential loss at η:
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Robust line fitting and prediction intervals
Fit y = 1 + 2x + noise (σ = 1), 200 points, with growing fractions of gross upward outliers (+20 to +60). Mean absolute slope error over 20 datasets (true slope 2):
| outliers | least squares | L1 | Huber (δ = 1) |
|---|---|---|---|
| 0% | 0.020 | 0.028 | 0.023 |
| 10% | 0.236 | 0.031 | 0.024 |
| 20% | 0.235 | 0.020 | 0.024 |
| 30% | 0.307 | 0.043 | 0.045 |
On clean data, least squares is (slightly) the most efficient. With outliers it degrades by about 10×, while L1 and Huber barely move. Fitting the 0.1 and 0.9 quantile lines by pinball-loss IRLS gives a band that covers 79.9% of new points, a calibrated 80% prediction interval. Robust losses are standard in SLAM back-ends (Huber and Cauchy kernels in bundle adjustment) and in sensor fusion.
Losses in AI, robotics and aerospace
- Robust estimation: M-estimators (Huber, Cauchy, Tukey) in SLAM, bundle adjustment and visual odometry; RANSAC for gross outliers.
- Perception: cross-entropy for classification, focal loss for class imbalance, calibrated probabilities for downstream planning.
- Uncertainty: quantile regression and conformal prediction for prediction intervals with guaranteed coverage.
- Control and RL: cost design is the loss design of control; reward shaping changes the optimal policy.
References
- P. Bartlett, M. Jordan, J. McAuliffe (2006). “Convexity, classification, and risk bounds.” JASA, 101.
- T. Zhang (2004). “Statistical behavior and consistency of classification methods based on convex risk minimization.” Annals of Statistics, 32.
- P. Huber, E. Ronchetti (2009). Robust Statistics, 2nd ed. Wiley.
- R. Koenker (2005). Quantile Regression. Cambridge.
- T. Gneiting, A. Raftery (2007). “Strictly proper scoring rules, prediction, and estimation.” JASA, 102.