Lesson 6.2 · 8 min read · about 50 min to master at a very slow pace

MSE, MAE and Asymmetric Losses

Regression losses compared: MSE punishes big errors hard and estimates the mean; MAE is robust to outliers and estimates the median; pinball losses price over- and under-prediction differently.

Not startedJump to quiz

The regression losses

LossFormula (average over )Property
MSE (L2)Estimates the mean; large errors dominate
MAE (L1)Estimates the median; robust to outliers
Pinball (asymmetric) if , if , with Different prices for over- and under-prediction

Why MAE resists outliers

0369-3-2-10123error ŷ − y
MSE: e²MAE: |e|
The loss for one prediction.
-6-3036-3-2-10123error ŷ − y
MSE gradient: 2eMAE gradient: ±1
Its derivative: MSE's grows with the error.

MSE's gradient is proportional to the error, so one huge residual can dominate the whole update. MAE's gradient has the same size (±1) however big the error, so a few outliers have limited pull. MAE isn't differentiable at exactly zero; a valid subgradient (any value in , usually 0) is used there.

Worked example: mean vs median

Targets . The single number that minimises MSE is the mean, 22. The one that minimises MAE is the median, 3. One outlier drags the MSE answer far from the typical value.

Asymmetric losses

When over-predicting and under-predicting cost different amounts (running out of stock versus holding extra), the pinball loss weights them differently: with and , under-predicting costs three times as much as over-predicting, so the model learns to aim high.

For any regression loss, use a linear output: a sigmoid would restrict the predictions to (0, 1).

Stuck? Common doubts

Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.

Going deeperIf MAE is more robust, why is MSE so common?

MSE is smooth everywhere, its gradient shrinks near the optimum (which helps convergence), and it matches the assumption of Gaussian noise. MAE is preferable when the data has outliers you don't want to chase. Many practitioners use a hybrid (the Huber loss) that is quadratic near zero and linear far away.

Cheatsheet

MSE vs MAE

MSE: estimates the mean; gradient , outliers dominate. MAE: estimates the median; gradient , robust; subgradient at 0.

Pinball loss

: if , if . Different costs for over- and under-prediction.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateTargets . Which single prediction minimises MSE, and which minimises MAE?
Q2conceptWhy does one huge outlier affect an MSE-trained model much more than an MAE-trained one?
Q3conceptMAE is not differentiable at an error of exactly zero. How is it handled?
Q4applyA shop forecasts demand. Running out costs three times as much as overstocking. Which loss fits?
Q5applyYou use a sigmoid output for a regression network predicting prices in thousands. What goes wrong?