{
  "id": "mean-absolute-error",
  "title": "Mean Absolute Error",
  "lang": "en",
  "source_lang": "en",
  "summary": "Mean absolute error is the average absolute difference between predicted and observed values, measuring prediction accuracy in the original units of the data.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "MAE",
    "Mean absolute prediction error",
    "Mean absolute residual"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/mean-absolute-error/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/mean-absolute-error/",
      "json": "https://aiwiki.page/zh/mean-absolute-error.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "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."
    },
    {
      "heading": "Definition",
      "text": "For \\(n\\) observed values \\(y_1,\\ldots,y_n\\) and corresponding predictions \\(\\hat y_1,\\ldots,\\hat y_n\\), mean absolute error is\n\n\\[\\operatorname{MAE} = \\frac{1}{n}\\sum_{i=1}^{n}|y_i-\\hat y_i|.\\]\n\nThe signed error may be defined as either \\(y_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.\n\nMAE has several immediate properties:\n\n- It is nonnegative.\n- It equals zero exactly when every prediction equals its corresponding observation.\n- Positive and negative errors cannot cancel.\n- It has the same physical units as the observations.\n- Each observation contributes in direct proportion to the magnitude of its error.\n\nFor example, observations of \\(3,5,2,7\\) and predictions of \\(2,5,4,6\\) give absolute errors of \\(1,0,2,1\\). Their MAE is\n\n\\[\\frac{1+0+2+1}{4}=1.\\]\n\nThis means that the average absolute discrepancy is one unit; it does not mean that every prediction is one unit from its observation.\n\nPopulation version\n\nFor an outcome \\(Y\\) and prediction \\(\\hat Y\\), the population counterpart is the expected absolute error\n\n\\[R=\\mathbb{E}\\!\\left[|Y-\\hat Y|\\right],\\]\n\nprovided this expectation is finite. Here \\(Y\\) and \\(\\hat Y\\) are random variables with a specified joint distribution.\n\nFor 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."
    },
    {
      "heading": "Mathematical properties",
      "text": "Scaling and translation\n\nAdding the same constant to observations and predictions leaves MAE unchanged. Multiplying both by a constant \\(c\\) multiplies MAE by \\(|c|\\). More generally,\n\n\\[\\operatorname{MAE}(a+cy,\\;a+c\\hat y) = |c|\\,\\operatorname{MAE}(y,\\hat y).\\]\n\nThus, converting measurements from metres to centimetres multiplies MAE by \\(100\\). 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.\n\nRelation to distance and norms\n\nFor vectors \\(y,\\hat y\\in\\mathbb{R}^n\\),\n\n\\[\\operatorname{MAE}(y,\\hat y) = \\frac{1}{n}\\|y-\\hat y\\|_1,\\]\n\nwhere \\(\\|\\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.\n\nThis geometric interpretation concerns paired coordinates. Arbitrarily reordering one vector can change MAE even when its collection of values remains unchanged."
    },
    {
      "heading": "Absolute error and the median",
      "text": "A central property of absolute-error loss is that it targets the median, rather than the mean.\n\nFor a real-valued random variable \\(Y\\) with finite first absolute moment, every median minimizes\n\n\\[\\mathbb{E}[|Y-a|]\\]\n\nover constant predictions \\(a\\). A median \\(m\\) satisfies\n\n\\[\\Pr(Y\\leq m)\\geq \\frac12, \\qquad \\Pr(Y\\geq m)\\geq \\frac12.\\]\n\nThe 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.\n\nIn prediction from input variables \\(X\\), minimizing expected absolute loss over unrestricted prediction functions targets a conditional median of \\(Y\\) given \\(X\\). By contrast, minimizing mean squared error targets the conditional mean when the relevant moments exist.\n\nThis 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."
    },
    {
      "heading": "Use in model fitting",
      "text": "Minimizing the sum or mean of absolute residuals is called least absolute deviations estimation. In linear regression, it takes the form\n\n\\[\\min_{\\beta} \\frac{1}{n} \\sum_{i=1}^{n}|y_i-x_i^\\top\\beta|.\\]\n\nThe objective is a convex function of \\(\\beta\\), although a unique solution is not guaranteed.\n\nOptimization\n\nAbsolute error is not differentiable where a residual is zero. For a single observation, differentiation with respect to the prediction gives\n\n\\[\\frac{\\partial}{\\partial \\hat y}|y-\\hat y| = \\begin{cases} -1,&\\hat y<y,\\\\ 1,&\\hat y>y. \\end{cases}\\]\n\nAt \\(\\hat y=y\\), its subgradient is the interval \\([-1,1]\\). Thus, away from zero error, the slope has constant magnitude rather than increasing with error size.\n\nLinear absolute-error fitting can be expressed as a linear program by introducing auxiliary variables \\(u_i\\):\n\n\\[\\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}\\]\n\nThe constraints ensure that the smallest feasible \\(u_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.\n\nProbabilistic interpretation\n\nAbsolute-error fitting also has a maximum likelihood interpretation. Suppose independent errors follow a Laplace distribution with common scale \\(b>0\\):\n\n\\[p(y_i\\mid x_i,\\beta,b) = \\frac{1}{2b} \\exp\\!\\left( -\\frac{|y_i-x_i^\\top\\beta|}{b} \\right).\\]\n\nFor fixed \\(b\\), 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."
    },
    {
      "heading": "Comparison with squared-error measures",
      "text": "The root mean squared error is\n\n\\[\\operatorname{RMSE} = \\sqrt{\\frac1n\\sum_{i=1}^n(y_i-\\hat y_i)^2}.\\]\n\nFor the same finite set of errors,\n\n\\[\\operatorname{MAE}\\leq\\operatorname{RMSE},\\]\n\nwith equality exactly when all absolute errors are equal.\n\nMAE 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.\n\nMAE is often described as less sensitive to extreme errors than squared-error measures. This is a relative statement, not a claim of complete robustness:\n\n- Absolute loss remains unbounded, so a sufficiently large error can dominate an average.\n- Robustness of a fitted model depends on its predictors and model structure, not only its loss function.\n- In regression, observations with extreme predictor values can still exert substantial influence.\n\nMAE 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."
    },
    {
      "heading": "Weighted and related measures",
      "text": "A weighted MAE is\n\n\\[\\operatorname{MAE}_w = \\frac{\\sum_{i=1}^n w_i|y_i-\\hat y_i|} {\\sum_{i=1}^n w_i},\\]\n\nwhere \\(w_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.\n\nMAE should be distinguished from:\n\n- Mean absolute deviation: an average absolute distance from a specified center, such as a sample mean or median, rather than necessarily from paired predictions.\n- Median absolute error: the median of the individual absolute errors, rather than their average.\n- Mean absolute percentage error: an average of absolute errors relative to observed values; unlike MAE, it is undefined at zero observations.\n- Quantile loss: an asymmetric extension of absolute loss used to estimate a chosen quantile. At the median quantile, it is proportional to absolute loss."
    },
    {
      "heading": "Interpretation and evaluation limits",
      "text": "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.\n\nSeveral qualifications affect its interpretation:\n\nEvaluation 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.\n\nLoss 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.\n\nDependence 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.\n\nAggregation 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.\n\nUncertainty 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."
    }
  ],
  "links": [
    "absolute-value",
    "statistics",
    "machine-learning",
    "loss-function",
    "expected-value",
    "random-variable",
    "law-of-large-numbers",
    "norm-mathematics",
    "triangle-inequality",
    "median",
    "mean-squared-error",
    "linear-regression",
    "convex-function",
    "linear-programming",
    "maximum-likelihood-estimation",
    "laplace-distribution",
    "quantile",
    "time-series",
    "training-data",
    "cross-validation",
    "standard-error",
    "confidence-interval"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}