Scoring Regressions
MAE vs RMSE
In this post
We are surrounded by a plethora of engineering marvels and challenges, offering great examples and potential for improvement and optimisation: from something as simple as people’s health schedules to determining the shape of a giant A380 aircraft wing. The modern world works on one word doing all the heavy lifting for us: OPTIMISATION. The word itself reflects the idea of improving, and continually improving, toward perfection, much like our human instincts for many things.
And here’s the surprising part. Once you start looking, the same two characters keep showing up everywhere, each time in a different form: the L1 and L2 norms. This series is going to take a short tour (sometimes detours XD) through the four places I keep bumping into them.
TL;DR of the series
The same two norms wear four different hats:
- Measuring error (this post): MAE and RMSE score a model that’s already fitted.
- Choosing a loss (The Cost of Deviations): the rule the optimiser uses to fit the model in the first place.
- Regularisation: still a loss, but charged on the model’s parameters, with a more nuanced meaning.
- Estimation: L2 meets probability, in things like the Kalman filter and its robust cousins.
Choosing an objective function is choosing, in a way, what kind of errors made by the model deserve the optimiser’s attention, and by how much. Looking at the behaviour of the objective function tells you a lot about what your model assumes.
First: scoring vs. shaping
Before we go deep into choosing which objective to optimise, and which model to fit, let us first talk about how to score the deviations (errors) our model’s output is gonna give.
- A metric reports a model’s error. Metrics describe a finished, fitted model. (This post.)
- A loss is the function we choose to shape the model. (Next post: The Cost of Deviations.)
Here we discuss the two metrics built on the L1 and L2 norms: MAE and RMSE. You’ll see them quite often, for example whenever different SLAM algorithms are compared on the same datasets. For an error vector \(e \in \mathbb{R}^n\) given by \((e_1, e_2, \dots, e_n)\):
MAE: Mean Absolute Error
\[\text{MAE} = \frac{1}{n}\sum_{i=1}^{n} \lvert e_i \rvert = \frac{1}{n}\lVert e \rVert_1\]Drop the minus signs, then take the average. Every unit of error counts the same.
RMSE: Root Mean Squared Error
\[\text{RMSE} = \sqrt{\frac{1}{n}\sum_{i=1}^{n} e_i^2} = \frac{\lVert e \rVert_2}{\sqrt{n}}\]Square every error, average, then square-root back to normal units. Big errors count a lot more.
We will try to go beyond these mere formula definitions and understand qualitatively what implications they have. Now, let’s look at some examples.
Five models, five mistakes each
Take the same 5 data points and 5 different fitted models. Each model gives rise to a different set of error values on those points:
| Model | Errors | MAE | RMSE |
|---|---|---|---|
| A | 3, 3, 3, 3, 3 | 3 | 3 |
| B | 1, 2, 3, 4, 5 | 3 | \(\sqrt{11} \approx 3.32\) |
| C | 0, 0, 0, 0, 15 | 3 | \(\sqrt{45} \approx 6.71\) |
| D | 1, 1, 3, 3, 5 | 2.6 | 3 |
| E | 0, 0, 0, 0, \(\sqrt{45}\) | \(\approx 1.34\) | 3 |
Story 1: Same MAE, different vibes
Look at A, B and C. All have the same MAE, but looking at the error values, they still feel different. A is steady. B wobbles. C is perfect four times, then makes one huge blunder.
If we look at RMSE, it captures this quite interestingly well: \(\text{RMSE}_A = 3 < \text{RMSE}_B \approx 3.32 < \text{RMSE}_C \approx 6.71\). The larger the variation, the more RMSE picks it up. RMSE dislikes big mistakes being made.
Fun fact: why does this happen?
There’s a neat identity hiding here:
\[\text{RMSE}^2 = \text{MAE}^2 + \big(\text{spread of the error sizes } \lvert e_i \rvert\big)^2\]where “spread” is the standard deviation. So RMSE is MAE plus a penalty for uneven mistakes. For model C: \(3^2 + 6^2 = 45\), and \(\sqrt{45} \approx 6.71\).
Story 2: Same RMSE, different MAE
Now look at A, D and E. All have the same RMSE. But when you look at the data, they clearly differ in how many outliers they have: A is steady 3s (MAE 3), D is a mix (MAE 2.6), and E is four perfect predictions plus one big miss (MAE ≈ 1.34). MAE sees that E is mostly good: it counts each mistake at its actual size, so a rare outlier doesn’t take over the score.
A good interpretation
MAE: the average error size.
RMSE: the average mistake size, where big mistakes weigh more.
Who should be graded how?
A surgical robot: use RMSE
When a surgical robot positions its tool, lots of tiny errors are harmless, but a single large one can be fatal. Judge its precision on RMSE, not MAE, so that one big miss counts.
Airline delays: use MAE
Delays in airline operations can be assessed using MAE. A 10-minute delay is a 10-minute delay.
The bounds, and what the gap tells us
\[\text{MAE} \;\le\; \text{RMSE} \;\le\; \sqrt{n}\cdot\text{MAE}\]- RMSE = MAE holds when every error has the same absolute value: \([-5, 5]\), \([5, 5]\) and \([-5, -5]\) all count as “all fives”. That’s model A.
- RMSE = \(\sqrt{n}\,\)MAE when all errors except one are zero. That’s models C and E (here \(n = 5\), so \(\sqrt{5} \approx 2.24\)).
Both MAE and RMSE indicate the typical size of the error in their own ways. But their ratio, somewhere in \([1, \sqrt{n}]\), tells you how much the error magnitudes vary and how concentrated they are around a particular value:
all mistakes the same size
one big mistake, the rest zero
Quick read
RMSE ≈ MAE ⇒ consistent errors
RMSE ≫ MAE ⇒ uneven errors, usually a few big ones
Side note: squaring doesn’t always penalise more
Note that \(0.5^2 = 0.25\) but \(3^2 = 9\). RMSE’s squaring rule penalises errors smaller than 1 less and errors larger than 1 more, so it penalises large deviations disproportionately more than small ones.
So, when do you want which metric?
Pick MAE when…
- every unit of error matters equally
- you want robustness to outlier-like situations
- you like median-like behaviour (more in The Cost of Deviations!)
- large mistakes aren’t catastrophic (nothing safety-critical)
e.g. predicting arrival times for fixed-schedule flights
Pick RMSE when…
- large errors should count extra
- you want to punish and measure outliers as well
e.g. collision avoidance; position estimation, so we know how badly a model behaves over the entire course
Up next: The Cost of Deviations
This article was about scoring mistakes made by a given fitted model: metrics for assessing how good a fitted model is. But how do we find a good model to fit in the first place?! Let’s find out!!
If you would like the next part in your inbox, you can subscribe on Substack.