Mean Absolute Error (MAE) averages the absolute value of every prediction error — treating every unit of error equally, regardless of size, unlike MSE's disproportionate penalty on large mistakes.
Formula
Worked Example
Same residuals as MSE's example: \([0.2, 0.6, -1.0, -0.6, 0.8]\).
from sklearn.metrics import mean_absolute_error
y_true = [52, 58, 62, 68, 75]
y_pred = [51.8, 57.4, 63.0, 68.6, 74.2]
print(mean_absolute_error(y_true, y_pred)) # 0.64
MAE (0.64) directly answers "on average, how many marks off is a typical prediction?" — a more intuitive, directly interpretable number than MSE's squared-units 0.48.
MAE vs MSE — When Each Wins
| MAE | MSE | |
|---|---|---|
| Outlier sensitivity | Lower — errors scale linearly | Higher — errors scale quadratically |
| Units | Same as the target — directly interpretable | Squared units — less intuitive |
| Differentiable at zero error? | No — a sharp corner in the loss curve | Yes, smoothly |
| Best for | Data with outliers you don't want to dominate the score | When large errors are genuinely much worse than small ones |
A Concrete Illustration of the Difference
from sklearn.metrics import mean_absolute_error, mean_squared_error
y_true = [10, 20, 30, 40, 50]
y_pred_normal = [12, 18, 32, 38, 52] # small, consistent errors
y_pred_outlier = [11, 19, 31, 39, 100] # one huge error, rest are tiny
print("Normal errors -- MAE:", mean_absolute_error(y_true, y_pred_normal),
" MSE:", mean_squared_error(y_true, y_pred_normal))
print("Outlier errors -- MAE:", mean_absolute_error(y_true, y_pred_outlier),
" MSE:", mean_squared_error(y_true, y_pred_outlier))
# MSE jumps dramatically for the outlier case; MAE rises much more modestly --
# MSE's squaring makes it far more sensitive to that single large miss
Practical Use Cases
- Reporting model error to a non-technical audience — "on average, off by ₹0.64 lakh" is immediately understandable
- Data with known, expected outliers you don't want to disproportionately dominate the evaluation
Common Mistakes
- Using MAE as a training loss with gradient-based methods without accounting for its non-differentiability at zero error — some optimizers handle this fine, others need adjustment.
- Assuming MAE and MSE will always rank two models the same way — a model with many small errors vs one with fewer but larger errors can rank differently under each metric.
Interview Relevance
Q: "You have a regression dataset with a few extreme, known-legitimate outliers. Would you report MAE or MSE as your primary metric?" MAE — its linear error scaling keeps the outliers from dominating the reported score, giving a more representative sense of the model's typical performance, whereas MSE's squaring would make the metric mostly reflect how the model handles those few extreme cases.
Practice Question
Given actual values \([100, 200, 300]\) and predictions \([110, 190, 305]\), compute MAE by hand and compare it to the MSE you computed in the MSE note's practice question.