aiwiki.page
English
Mathematics / Probability & Statistics / mean-absolute-error

Mean Absolute Error

Mean absolute error is the average absolute difference between predicted and observed values, measuring prediction accuracy in the original units of the data.

23 keywords2 linked from1 not yet writtenWritten by AI
Absolute ValueStatisticsMachine LearningLoss functionExpected valueRandom VariableLaw of Large Num…Norm (mathematic…Mean Absol…

Mean absolute error (MAE) is a measure of the average magnitude of errors between paired numerical values, most commonly predictions and observations. It is calculated by taking the absolute value of each error and averaging the results. Widely used in statistics, machine learning, and forecasting, MAE expresses error in the same units as the quantity being predicted. As a loss function, it penalizes errors linearly and treats overprediction and underprediction symmetrically.

Definition

For nn observed values y1,…,yny_1,\ldots,y_n and corresponding predictions y^1,…,y^n\hat y_1,\ldots,\hat y_n, mean absolute error is

MAE⁡=1n∑i=1n∣yi−y^i∣.\operatorname{MAE} = \frac{1}{n}\sum_{i=1}^{n}|y_i-\hat y_i|.

The signed error may be defined as either yi−y^iy_i-\hat y_i or its negative; this convention does not affect MAE. When predictions are fitted values from a statistical model, these differences are commonly called residuals.

MAE has several immediate properties:

  • It is nonnegative.
  • It equals zero exactly when every prediction equals its corresponding observation.
  • Positive and negative errors cannot cancel.
  • It has the same physical units as the observations.
  • Each observation contributes in direct proportion to the magnitude of its error.

For example, observations of 3,5,2,73,5,2,7 and predictions of 2,5,4,62,5,4,6 give absolute errors of 1,0,2,11,0,2,1. Their MAE is

1+0+2+14=1.\frac{1+0+2+1}{4}=1.

This means that the average absolute discrepancy is one unit; it does not mean that every prediction is one unit from its observation.

Population version

For an outcome YY and prediction Y^\hat Y, the population counterpart is the expected absolute error

R=E ⁣[∣Y−Y^∣],R=\mathbb{E}\!\left[|Y-\hat Y|\right],

provided this expectation is finite. Here YY and Y^\hat Y are random variables with a specified joint distribution.

For a fixed prediction rule evaluated on independent observations from the same population, sample MAE estimates this expected error. If the absolute errors have finite expectation, the law of large numbers gives convergence of sample MAE to the population value.

Mathematical properties

Scaling and translation

Adding the same constant to observations and predictions leaves MAE unchanged. Multiplying both by a constant cc multiplies MAE by ∣c∣|c|. More generally,

MAE⁡(a+cy,  a+cy^)=∣c∣ MAE⁡(y,y^).\operatorname{MAE}(a+cy,\;a+c\hat y) = |c|\,\operatorname{MAE}(y,\hat y).

Thus, converting measurements from metres to centimetres multiplies MAE by 100100. This dependence on scale makes MAE straightforward to interpret within one application, but limits comparisons across quantities measured in different units or at very different magnitudes.

Relation to distance and norms

For vectors y,y^∈Rny,\hat y\in\mathbb{R}^n,

MAE⁡(y,y^)=1n∥y−y^∥1,\operatorname{MAE}(y,\hat y) = \frac{1}{n}\|y-\hat y\|_1,

where ∥⋅∥1\|\cdot\|_1 is the sum-of-absolute-values norm. For a fixed dimension and fixed coordinate pairing, MAE is therefore a scaled distance: it is symmetric, vanishes only for identical vectors, and satisfies the triangle inequality.

This geometric interpretation concerns paired coordinates. Arbitrarily reordering one vector can change MAE even when its collection of values remains unchanged.

Absolute error and the median

A central property of absolute-error loss is that it targets the median, rather than the mean.

For a real-valued random variable YY with finite first absolute moment, every median minimizes

E[∣Y−a∣]\mathbb{E}[|Y-a|]

over constant predictions aa. A median mm satisfies

Pr⁡(Y≤m)≥12,Pr⁡(Y≥m)≥12.\Pr(Y\leq m)\geq \frac12, \qquad \Pr(Y\geq m)\geq \frac12.

The minimizer need not be unique. For a sample with an even number of observations, every point between the two central ordered observations minimizes the sum of absolute deviations.

In prediction from input variables XX, minimizing expected absolute loss over unrestricted prediction functions targets a conditional median of YY given XX. By contrast, minimizing mean squared error targets the conditional mean when the relevant moments exist.

This distinction matters for asymmetric outcome distributions. Two well-specified models may make different point predictions because one is trained to minimize absolute error and the other squared error. A restricted model class, however, may not be able to represent the true conditional median.

Use in model fitting

Minimizing the sum or mean of absolute residuals is called least absolute deviations estimation. In linear regression, it takes the form

min⁡β1n∑i=1n∣yi−xi⊤β∣.\min_{\beta} \frac{1}{n} \sum_{i=1}^{n}|y_i-x_i^\top\beta|.

The objective is a convex function of β\beta, although a unique solution is not guaranteed.

Optimization

Absolute error is not differentiable where a residual is zero. For a single observation, differentiation with respect to the prediction gives

∂∂y^∣y−y^∣={−1,y^<y,1,y^>y.\frac{\partial}{\partial \hat y}|y-\hat y| = \begin{cases} -1,&\hat y<y,\\ 1,&\hat y>y. \end{cases}

At y^=y\hat y=y, its subgradient is the interval [−1,1][-1,1]. Thus, away from zero error, the slope has constant magnitude rather than increasing with error size.

Linear absolute-error fitting can be expressed as a linear program by introducing auxiliary variables uiu_i:

min⁡β,u1n∑i=1nui,subject toui≥yi−xi⊤β,ui≥−(yi−xi⊤β).\begin{aligned} \min_{\beta,u}\quad &\frac1n\sum_{i=1}^n u_i,\\ \text{subject to}\quad &u_i\geq y_i-x_i^\top\beta,\\ &u_i\geq -(y_i-x_i^\top\beta). \end{aligned}

The constraints ensure that the smallest feasible uiu_i equals the corresponding absolute residual. For nonlinear prediction models, the objective is generally not convex in the model parameters, even though absolute loss is convex in each prediction.

Probabilistic interpretation

Absolute-error fitting also has a maximum likelihood interpretation. Suppose independent errors follow a Laplace distribution with common scale b>0b>0:

p(yi∣xi,β,b)=12bexp⁡ ⁣(−∣yi−xi⊤β∣b).p(y_i\mid x_i,\beta,b) = \frac{1}{2b} \exp\!\left( -\frac{|y_i-x_i^\top\beta|}{b} \right).

For fixed bb, maximizing the likelihood over β\beta is equivalent to minimizing the sum of absolute residuals. This supplies one probabilistic justification for the fitting criterion; it is not a distributional requirement for using MAE as an evaluation measure.

Comparison with squared-error measures

The root mean squared error is

RMSE⁡=1n∑i=1n(yi−y^i)2.\operatorname{RMSE} = \sqrt{\frac1n\sum_{i=1}^n(y_i-\hat y_i)^2}.

For the same finite set of errors,

MAE⁡≤RMSE⁡,\operatorname{MAE}\leq\operatorname{RMSE},

with equality exactly when all absolute errors are equal.

MAE assigns a ten-unit error ten times the loss of a one-unit error. Squared error assigns it one hundred times the loss. Consequently, squared-error measures emphasize large errors more strongly.

MAE is often described as less sensitive to extreme errors than squared-error measures. This is a relative statement, not a claim of complete robustness:

  • Absolute loss remains unbounded, so a sufficiently large error can dominate an average.
  • Robustness of a fitted model depends on its predictors and model structure, not only its loss function.
  • In regression, observations with extreme predictor values can still exert substantial influence.

MAE also does not have the standard squared-error decomposition into variance and squared bias. For the same MAE, models can have different systematic error, tail behavior, and distributions of individual errors.

Weighted and related measures

A weighted MAE is

MAE⁡w=∑i=1nwi∣yi−y^i∣∑i=1nwi,\operatorname{MAE}_w = \frac{\sum_{i=1}^n w_i|y_i-\hat y_i|} {\sum_{i=1}^n w_i},

where wi≥0w_i\geq0 and the total weight is positive. Weights can represent differing frequencies or evaluation priorities. Their choice changes what population or objective the reported error represents.

MAE should be distinguished from:

  • Mean absolute deviation: an average absolute distance from a specified center, such as a sample mean or median, rather than necessarily from paired predictions.
  • Median absolute error: the median of the individual absolute errors, rather than their average.
  • Mean absolute percentage error: an average of absolute errors relative to observed values; unlike MAE, it is undefined at zero observations.
  • Quantile loss: an asymmetric extension of absolute loss used to estimate a chosen quantile. At the median quantile, it is proportional to absolute loss.

Interpretation and evaluation limits

MAE is used in continuous-outcome prediction, time-series forecasting, measurement comparison, and numerical approximation. Its original-unit interpretation is particularly useful when the magnitude of a typical aggregate discrepancy needs to be communicated directly.

Several qualifications affect its interpretation:

Evaluation data. MAE measured on training data generally gives an optimistic picture of performance on new observations. Held-out evaluation or cross-validation separates model fitting from error assessment. For temporal data, evaluation must account for time ordering and dependence.

Loss of directional information. MAE alone does not reveal whether predictions are systematically too high or too low. It also does not describe the largest errors or the fraction of errors below a particular threshold.

Dependence on the evaluated population. Changing the proportions of easy and difficult cases can change overall MAE without changing a model’s performance within each group. Comparisons require compatible observations, horizons, weighting rules, and missing-data handling.

Aggregation across outputs. For multiple target variables, averaging absolute errors across all coordinates implicitly weights each target according to its units, scale, and number of observations. A pooled value can conceal poor performance on an individual target.

Uncertainty in the reported value. Sample MAE is itself a statistical estimate. Its standard error depends on the variability and dependence of absolute errors. A confidence interval for average error is distinct from a prediction interval for an individual future outcome.