The mean absolute error (MAE) measures how wrong a regression model is by averaging the size of its mistakes, ignoring their direction. You take the absolute value of every residual — the raw gap between prediction and truth — and average them. Because it never squares anything, MAE treats a big miss and a small miss in proportion, which makes it the go-to loss whenever your data contains outliers you do not want to chase. It is the honest, plain-spoken cousin of the mean squared error.

What is the MAE?
MAE answers a very intuitive question: on average, by how much does my model miss? For each example you compute the residual, drop its sign with the absolute value, and average across the dataset. The result is in the same units as the target, so if you are predicting temperatures in degrees, an MAE of 2 literally means “off by two degrees on average.” That direct readability is one of the biggest reasons practitioners like the MAE — there is no squaring or square-rooting to mentally undo.
You will also see it called the L1 loss or absolute loss. Whatever the name, it is built from the same absolute residuals, and it is the natural partner to the median in the way that squared error is the natural partner to the mean.
The mean absolute error formula
With n examples, true values yi and predictions ŷi, you sum the absolute errors and divide by the count. The mean absolute error formula has no exponent, which is exactly what gives it its robust, linear character: doubling an error only doubles its contribution, rather than quadrupling it as squaring would.
See it: how the MAE grows
The blue V-shaped line is the loss from a single prediction as its error moves away from zero; the orange dashed line is the gradient. Notice the loss rises in a straight line, and the gradient is a constant ±1 — it does not care how large the error is, only which side of zero it is on.
A worked example
Reuse the house-price model: true values 200, 250, 300; predictions 210, 230, 340. The absolute errors are 10, 20 and 40, so the MAE is (10 + 20 + 40) / 3:
Compare this with the MSE: the $40k miss contributes 40 to the MAE total but 1600 to the MSE total. That is the whole story of robustness in one example — the MAE lets the outlier speak with a normal voice, while squared error lets it shout.
Why the MAE is robust to outliers
This makes MAE the sensible default when your dataset contains occasional wild readings — sensor glitches, data-entry errors, or genuinely rare events — that you would rather the model not bend over backwards to fit.
The gradient and its one weakness
Mean absolute error vs MSE
| Aspect | MAE (L1) | MSE (L2) |
|---|---|---|
| Outliers | robust | very sensitive |
| Gradient | constant ±1, kink at 0 | smooth, shrinks near 0 |
| Fits toward | median | mean |
| Units | same as target | squared |
Neither is universally better. If big errors are genuinely the most costly thing, the mean squared error is right to punish them. If big errors are usually noise, the MAE is the wiser objective.
When to use the MAE
Choose MAE when your target has outliers you want the model to tolerate rather than chase, when you want a metric stakeholders can read at a glance in the original units, or when the cost of an error grows roughly linearly with its size rather than explosively. It is especially popular in demand forecasting and finance, where a single freak day should not dominate the whole evaluation.
Common mistakes to avoid
Mean absolute error in Python
import numpy as np
from sklearn.metrics import mean_absolute_error
y_true = np.array([200, 250, 300])
y_pred = np.array([210, 230, 340])
print(mean_absolute_error(y_true, y_pred)) # 23.33
print(np.mean(np.abs(y_true - y_pred))) # 23.33In PyTorch it is torch.nn.L1Loss(); in Keras, loss="mae". See the Wikipedia mean absolute error article for more.
Putting it into practice
A reliable habit is to report the MAE alongside the RMSE for every regression model. When the two are close, your errors are fairly uniform; when the RMSE is much larger than the MAE, a handful of big misses are inflating the squared metric, and those specific rows are worth inspecting. If you like MAE’s robustness but dislike its jittery gradient near the optimum, train with Huber loss, which behaves like squared error for small residuals and like the MAE for large ones, giving you the best of both. Whichever you optimise, always evaluate on a held-out set so the number reflects genuine generalisation rather than memorised training points.
Reading the mean absolute error like an expert
Because the mean absolute error lands in the target’s own units, the most valuable habit is to interpret it against the natural scale of the problem rather than in the abstract. Being off by two means something completely different when the typical value is ten than when it is ten thousand, so seasoned practitioners quote the figure as a percentage of the average target, turning it into a scale-free number that anyone on the team can judge at a glance. It also pays to look beyond the single average and inspect the full spread of the per-row errors: two models can share an identical mean absolute error while one is steadily mediocre and the other is usually excellent but occasionally terrible. A quick histogram of the individual errors, or a couple of percentiles such as the median and the ninetieth, exposes that difference instantly and often changes which model you would actually ship.
Pair it with a residual plot
Averaging hides direction entirely, so the mean absolute error should always travel with a simple plot of residuals against predicted values. That picture reveals whether the model tends to run high in one region and low in another — a systematic bias that no single averaged number can show, but which usually points straight at a missing feature, a needed transformation, or a target that should have been modelled on a logarithmic scale. When the residual cloud is centred and shapeless you can trust the headline figure; when it fans out or curves, the average is masking structure the model has not captured, and chasing a lower number without fixing that structure tends to produce brittle, overfit results. Treat the mean absolute error as the summary and the residual plot as the diagnosis, and you will make far better modelling decisions than the number alone could ever support.