Start studying
Module 1 · Machine Learning Module contents
Module 1  ·  Card 50 / 55beginner

MAE

MAE is the mean absolute error for regression.

You take the absolute difference between prediction and truth, then average.

It is in the same unit as the target, so it reads naturally.

It treats every error proportionally to its size.

It is more robust to outliers than squared-error metrics.

Learn in depth ↓
Module 01 · Machine Learning · 55 concepts
In depth  /  15 lines

MAE, in more detail

MAE is the average size of your mistakes, ignoring direction.

A miss of five below and a miss of five above count exactly the same.

Because it is a plain average, it reads in the units of the thing you predict.

An MAE of three thousand pounds on house prices means exactly that.

That makes it the easiest regression metric to explain to anyone.

It treats every mistake in proportion to its size.

Doubling an error doubles its contribution and no more than that.

So a handful of wild outliers cannot take over the score.

That is its main advantage over anything based on squared error.

It is the right choice when a big miss is not disproportionately worse.

Estimating delivery times is a good example of that.

Its downside is that it gives no extra weight to disasters.

If one enormous error would ruin your business, MAE underplays it.

It is also slightly awkward for some optimisers because of the sharp corner at zero.

Report it next to the average value of the target so people can judge the scale.

Want the full technical article? Wikipedia ↗
Deep dive

What is underneath MAE

The formula

MAE=1n∑i=1n∣yi−y^i∣\mathrm{MAE} = \frac{1}{n} \sum_{i=1}^{n} \left| y_i - \hat{y}_i \right|
  • yiy_i: the true value.
  • y^i\hat{y}_i: the prediction.
  • nn: how many examples.

The average size of the error, ignoring its sign. It is in the same units as the thing being predicted, so an MAE of 3.2 on house prices in thousands means the typical miss is 3200.

What the absolute value does to the gradient

∂∂y^∣y−y^∣=−sign(y−y^)\frac{\partial}{\partial \hat{y}} \left| y - \hat{y} \right| = -\mathrm{sign}(y - \hat{y})

The derivative is +1+1 or −1-1 and nothing else. It does not depend on how wrong the prediction is.

So an error of 100 pushes exactly as hard as an error of 0.1, which is the whole difference from squared error.

That makes MAE robust to outliers: one wildly wrong label cannot dominate the fit.

It also makes it awkward to optimise, because the gradient does not shrink as you approach the answer, and it is undefined at zero.

What it is estimating

Minimising absolute error gives you the median of the conditional distribution, not the mean.

arg⁡min⁡c  E[∣Y−c∣]=median(Y)\arg\min_{c} \; \mathbb{E}\left[ \left| Y - c \right| \right] = \mathrm{median}(Y)

That is a genuinely different prediction, and on a skewed target the two can be far apart.

If half your outcomes should be above the prediction and half below, MAE is the loss you want. If you want an unbiased average, it is not.

Against MSE

  1. MAE treats a big error as proportionally big; MSE treats it as quadratically big.
  2. MAE is robust to outliers; MSE is dominated by them.
  3. MAE predicts the median; MSE predicts the mean.
  4. MAE has a constant gradient; MSE has one that shrinks near the answer.
  5. MAE is in the target's units; MSE is in the target's units squared.

Neither is better. The question is whether an error twice as large is twice as bad or four times as bad, and only the problem can answer that.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
Why is MAE more robust to outliers than MSE?
Machine Learning

55 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close