Why Measure the Size of Prediction Errors?
A prediction can be above or below the outcome it is meant to predict. To summarize how far predictions are from observed outcomes, it helps to focus on the size of each miss, regardless of its direction. Mean absolute error, usually abbreviated MAE, does exactly this: it averages the absolute prediction errors across a specified set of cases.
For example, an MAE of 2.4 hours means that, across the cases being evaluated, the average absolute difference between predicted and observed outcomes is 2.4 hours. It does not mean every prediction misses by 2.4 hours, nor does it say whether predictions tend to be too high or too low. MAE is a summary of a set of prediction errors, expressed on the same measurement scale as the outcome.
Definition and Calculation
For each case \(i\), let \(y_i\) be its observed outcome and \(\hat{y}_i\) its predicted outcome. Define the prediction error as the observed value minus the predicted value. If there are \(n\) cases with both outcomes and predictions available, the MAE is the average of the absolute values of those errors.
The sign convention \(e_i=y_i-\hat{y}_i\) makes a positive error indicate that the observed outcome was larger than predicted, and a negative error indicate that it was smaller. Either way, the absolute error is nonnegative. If a source defines prediction error in the opposite direction, its signed errors have opposite signs, but its absolute errors and MAE are unchanged.
The calculation has three steps: find each observed-minus-predicted difference, take the absolute value of every difference, and divide their sum by the number of evaluated cases. The denominator is the number of cases with usable observed outcomes and predictions, not the number of predictors or the number of possible outcome values.
Worked Example: Prediction Errors for Energy Use
Suppose, in a hypothetical evaluation, a model predicts daily energy use for four homes. Energy use is measured in kilowatt-hours (kWh). The observed and predicted values are shown below; calculate the MAE.
| Home | Observed \(y_i\) (kWh) | Predicted \(\hat{y}_i\) (kWh) | Error \(e_i=y_i-\hat{y}_i\) (kWh) | Absolute error \(|e_i|\) (kWh) |
|---|---|---|---|---|
| 1 | 18 | 16 | 2 | 2 |
| 2 | 22 | 24 | -2 | 2 |
| 3 | 20 | 19 | 1 | 1 |
| 4 | 27 | 23 | 4 | 4 |
For example, Home 2 has error \(22-24=-2\) kWh, so its absolute error is \(|-2|=2\) kWh. The total absolute error is \(2+2+1+4=9\) kWh. Divide by the four evaluated homes:
For these four hypothetical homes, predictions differ from the observed daily energy use by an average of 2.25 kWh in absolute terms. This average describes the four evaluated cases; it does not imply that each home’s prediction is off by 2.25 kWh.
What the MAE Tells You
The unit of MAE is the unit of the outcome. If the outcome is measured in dollars, MAE is in dollars; if it is measured in minutes, MAE is in minutes. This follows because subtracting two outcomes measured in the same unit produces an error in that unit, taking an absolute value keeps the unit, and averaging values in one unit keeps that unit.
A useful interpretation names both the quantity being predicted and the evaluation cases. For instance, “the MAE is 1.8 days” is less informative than “for the evaluated cases, the model’s predictions of symptom duration were off by an average of 1.8 days in absolute terms.” The latter makes clear what was predicted, what the number summarizes, and the measurement scale.
Worked Example: Prediction Errors in Days
In a hypothetical exercise, a model predicts the duration of a symptom for five individuals. Both observed and predicted durations are in days. Calculate and interpret the MAE.
| Case | Observed duration (days) | Predicted duration (days) | Error (days) | Absolute error (days) |
|---|---|---|---|---|
| 1 | 4 | 5 | -1 | 1 |
| 2 | 7 | 6 | 1 | 1 |
| 3 | 5 | 8 | -3 | 3 |
| 4 | 10 | 7 | 3 | 3 |
| 5 | 8 | 9 | -1 | 1 |
The absolute errors sum to \(1+1+3+3+1=9\) days. There are five cases, so
For these five hypothetical cases, the average absolute prediction error for symptom duration is 1.8 days. Some cases have an absolute error below 1.8 days and others above it; MAE is an average, not a bound on any individual error. It also does not by itself indicate whether a prediction tended to be too high or too low.
Units, Scale, and the Evaluation Set
MAE is meaningful only when the errors being averaged refer to the same outcome, measured on a consistent scale. It would not make sense to combine an error of 3 minutes with an error of 2 dollars and report their average as though it had one outcome unit. If outcomes are converted to another unit, predictions must be converted in the same way before errors are calculated.
For example, if both observed and predicted commute times are recorded in minutes, the MAE is in minutes. Converting every time to hours divides every error magnitude, and therefore the MAE, by 60. The physical prediction differences have not changed; only the numerical representation and its unit have changed.
The cases used to calculate MAE also matter. A value calculated on training observations summarizes errors on those observations, while a value calculated on held-out evaluation observations summarizes errors on that evaluation set. These are different sets of cases and can give different MAEs. When a metric is meant to describe prediction performance on new cases, it should be calculated using an appropriate evaluation design rather than treated as an automatic description of performance beyond the observed cases.
The formula gives every included case equal weight. Consequently, when one case represents many people or has a different importance, ordinary MAE still gives it the same contribution as each other case. The result should be described as the average across the cases actually included, with the evaluation set and outcome units made clear.
Worked Example: Reporting MAE in a Different Time Unit
Suppose a hypothetical evaluation contains four commute-time predictions. The errors, in minutes, are \(4\), \(-7\), \(5\), and \(-10\). Calculate MAE in minutes, then express the same average in hours.
First take the absolute values: \(4\), \(7\), \(5\), and \(10\) minutes. Their sum is \(4+7+5+10=26\) minutes. Dividing by the four evaluated commutes gives
Since 60 minutes equal one hour, convert the average by dividing by 60:
Thus the same result can be reported as an average absolute prediction error of 6.5 minutes or about 0.1083 hours. The chosen unit should make the result easy to understand in context.
Why Absolute Values Come Before Averaging
The absolute value is essential to the definition: MAE averages error magnitudes, not signed errors. If the signs were retained, overpredictions and underpredictions could offset one another, so the resulting average would not describe the typical size of a miss. For example, signed errors of \(3\) and \(-3\) have average \(0\), even though both predictions differ from their outcomes by 3 units. Their absolute errors are \(3\) and \(3\), giving an MAE of \(3\) units.
A short justification establishes two basic properties. Each absolute error satisfies \(|e_i|\geq 0\), and the number of cases satisfies \(n>0\). Therefore their sum is nonnegative, and division by \(n\) keeps it nonnegative. Moreover, a sum of nonnegative numbers is zero only when every term is zero. Thus MAE is zero exactly when every evaluated prediction equals its observed outcome.
and
Common Mistakes
- Averaging signed errors instead of absolute errors. This can make the result look small when predictions miss in opposite directions. For MAE, take the absolute value of each error before adding.
- Dropping the outcome unit. A bare value such as “MAE = 2.25” is incomplete. Report “2.25 kWh,” “2.25 days,” or the appropriate unit.
- Interpreting the average as an error for every case. An MAE of 2.25 kWh does not mean every prediction is off by 2.25 kWh. It is the average of the absolute errors across the specified cases.
- Leaving the evaluation set unclear. MAE is calculated for the cases supplied to the formula. State whether these were training cases or evaluation cases when that distinction matters.
- Mixing outcome scales. Calculate errors only after observed outcomes and predictions are expressed in matching units on a consistent scale.
Check Your Understanding
Try these questions without looking back at the worked examples.
- For observed outcomes of 12 and 20 units and predictions of 10 and 23 units, calculate each signed error, each absolute error, and the MAE.
- A model has an MAE of 4.2 minutes on an evaluation set. What does this value mean, and what does it not imply about an individual prediction?
- Why must the absolute values be taken before the prediction errors are averaged?
- What is the MAE if every prediction exactly matches its observed outcome? Explain why.
- If all outcomes and predictions are converted from minutes to hours, what happens to the numerical value and unit of MAE?