All formulas

Statistics

Mean absolute error

stats.maeAlso called mean absolute error, mae, l1 loss, absolute error

MAE=1n∑i=1n∣yi−y^i∣\mathrm{MAE} = \frac{1}{n}\sum_{i=1}^{n} \left| y_i - \hat{y}_i \right|

Average of the absolute differences between observed and predicted values.

Notation

yy

observed values

y ∈ ℝn

y^\hat{y}

predicted values

ŷ ∈ ℝn

nn

number of observations

Size, at least 1

MAE\mathrm{MAE}

Result: the mean absolute error

scalar

Worked examples

Each result is solved exactly and confirmed by two independent computations.

  1. Given

    y=[1,2,3],y^=[1,1,5]y = [1, 2, 3], \hat{y} = [1, 1, 5]

    Result

    MAE=1\displaystyle \mathrm{MAE} = 1
  2. Given

    y=[0.5,−1],y^=[1,1]y = [0.5, -1], \hat{y} = [1, 1]

    Result

    MAE=54\displaystyle \mathrm{MAE} = \frac{5}{4}

    ≈ 1.25

  3. Given

    y=[−2],y^=[1]y = [-2], \hat{y} = [1]

    Result

    MAE=3\displaystyle \mathrm{MAE} = 3

Common mistakes

  • Sums instead of averaging

    The absolute errors are summed, giving n times the mean.

    Fix: Divide by n.

  • Missing absolute value

    Signed errors are averaged, so positive and negative errors cancel (this is the mean bias).

    Fix: Take the absolute value of each difference before averaging.

Source

  • Murphy 2022

    Murphy, Kevin P. Probabilistic Machine Learning: An Introduction. MIT Press, 2022.