How to Calculate Mean Absolute Error: Formula & Steps

Mean absolute error (MAE) is the average size of the errors in a set of predictions, calculated by taking the absolute difference between each predicted value and its actual value, then averaging those differences. An MAE of 0 means every prediction was perfect. The higher the number, the larger the average mistake.

The Formula

MAE = (1/n) × Σ|actual − predicted|

In plain terms: for each data point, subtract the predicted value from the actual value and drop any negative sign (that’s the absolute value part). Add up all those differences, then divide by the total number of data points (n). The result is your MAE.

Step-by-Step Calculation by Hand

Suppose you predicted the daily high temperature four times this week and want to know how accurate you were on average.

  • Day 1: Actual = 72°F, Predicted = 70°F → |72 − 70| = 2
  • Day 2: Actual = 65°F, Predicted = 68°F → |65 − 68| = 3
  • Day 3: Actual = 80°F, Predicted = 80°F → |80 − 80| = 0
  • Day 4: Actual = 74°F, Predicted = 71°F → |74 − 71| = 3

Now add the absolute errors: 2 + 3 + 0 + 3 = 8. Divide by the number of predictions: 8 / 4 = 2. Your MAE is 2°F, meaning your forecasts were off by 2 degrees on average.

Three steps, every time: find each absolute error, sum them, divide by the count.

How to Interpret the Result

One of MAE’s most useful qualities is that the result is in the same units as whatever you’re measuring. If you’re predicting house prices in dollars, your MAE is in dollars. If you’re predicting weight in kilograms, your MAE is in kilograms. This makes it immediately intuitive: an MAE of 15,000 on house prices means your model is off by $15,000 on average.

There’s no universal threshold for a “good” MAE because it depends entirely on context. An MAE of 5 is excellent if you’re predicting values that range from 0 to 10,000, but terrible if your values only range from 0 to 10. One practical approach is to compare your MAE against the range or average of the values you’re predicting. An MAE that’s small relative to the scale of your data suggests reasonable accuracy.

Calculating MAE in Excel

Put your actual values in column A and your predicted values in column B. In column C, calculate the absolute difference for each row using a formula like =ABS(A2-B2), then drag it down for all your data points. Finally, in an empty cell, use =AVERAGE(C2:C100) (adjusting the range to match your data) to get the MAE. That’s it: ABS for each row, then AVERAGE across them all.

Calculating MAE in Python

Python’s scikit-learn library has a built-in function that handles it in one line. Here’s a minimal example:

from sklearn.metrics import mean_absolute_error
y_true = [3, -0.5, 2, 7]
y_pred = [2.5, 0.0, 2, 8]
mean_absolute_error(y_true, y_pred)

This returns 0.5. The individual errors are 0.5, 0.5, 0, and 1, which sum to 2.0 and divide by 4 to give 0.5.

If you’d rather skip the library, you can do it with basic Python: take the absolute value of each difference, sum the list, and divide by its length.

MAE vs. MSE and RMSE

Mean squared error (MSE) and root mean squared error (RMSE) are the two metrics you’ll most often see compared to MAE. The core difference is in how they treat large errors.

MSE squares each error before averaging, which means a single big miss gets amplified dramatically. If one prediction is off by 10 while the rest are off by 1, squaring that 10 turns it into 100, pulling the overall metric way up. RMSE takes the square root of MSE to bring the units back in line with the original data, but it still inherits that sensitivity to large errors. MAE, by contrast, treats every error proportionally. An error of 10 counts exactly 10 times as much as an error of 1, no more.

This makes MAE more robust when your data contains outliers or when you care equally about all errors regardless of size. If a few large mistakes matter more to you than many small ones (say, predicting flood levels where underestimating a big flood is catastrophic), RMSE may be a better choice because it naturally penalizes those large errors more heavily. As far back as 1920, statisticians noted that minimizing absolute error often outperformed squared error in practice precisely because real-world data tends to include outliers that deviate from a tidy bell curve.

When MAE Is the Right Choice

MAE works well when you want a straightforward, easy-to-explain measure of average prediction error. It’s particularly useful in a few situations:

  • Your data has outliers. Because MAE doesn’t square errors, a handful of extreme values won’t distort your overall accuracy picture.
  • You need to communicate results to non-technical people. “Our model is off by an average of 3 units” is immediately understandable.
  • All errors matter equally. If being off by 20 is exactly twice as bad as being off by 10 (not four times as bad, as MSE would imply), MAE captures that linear relationship.

MAE is less ideal when you specifically want to punish large errors. In those cases, MSE or RMSE will flag models that occasionally produce wild predictions, even if their average error looks fine. Some practitioners calculate both MAE and RMSE side by side. When RMSE is substantially higher than MAE, it signals that a few predictions have much larger errors than the rest, which can guide you toward targeted improvements.