Mean Absolute Error

Mean absolute error (MAE) is a metric used to evaluate regression models. The MAE of a model is the average absolute difference between actual values and predicted values over all examples.

MAE = 1 m βˆ‘ i = 1 m | y i βˆ’ y ^ i |

where:

  • m is the number of examples
  • yi is the actual value of the label of the ith example
  • Ε·i is the predicted value of the label of the ith example

The lower the MAE, the better the model’s performance. The best possible MAE is 0.

Computing mean absolute error in scikit-learn

import numpy as np
from sklearn.metrics import mean_absolute_error

y_true = np.array([32, 38, 47, 58, 66, 73, 85, 91, 106, 116])
y_pred = np.array([32, 41, 50, 59, 68, 77, 86, 95, 104, 113])

mae = mean_absolute_error(y_true, y_pred)

print(f"MAE: {mae:.2f}")
MAE: 2.30

This page references the following sources:

Here are all the notes in this garden, along with their links, visualized as a graph.