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.
where:
-
m
is the number of examples -
yi is the actual value of the label
of the
i
th example -
Ε·i is the predicted value of the label
of the
i
th 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: