Mean absolute percentage error

The mean absolute percentage error (MAPE), also known as mean absolute percentage deviation (MAPD), is a measure of prediction accuracy of a forecasting method in statistics. It usually expresses the accuracy as a ratio defined by the formula:

MAPE=1001n∑t=1n|At−FtAt|

Where At is the actual value and Ft is the forecast value. Their difference is divided by the actual value At. The absolute value of this ratio is summed for every forecasted point in time and divided by the number of fitted points n. MAPE should be used with extreme caution in forecasting, because small actuals (target labels) can lead to highly inflated MAPE scores. wMAPE should be used instead of MAPE wherever possible (see section below).

MAPE in regression problems

Mean absolute percentage error is commonly used as a loss function for regression problems and in model evaluation, because of its very intuitive interpretation in terms of relative error.

Definition

Consider a standard regression setting in which the data are fully described by a random pair Z=(X,Y) with values in ℝd×ℝ, and n i.i.d. copies (X1,Y1),...,(Xn,Yn) of (X,Y). Regression models aim at finding a good model for the pair, that is a measurable function g from ℝd to ℝ such that g(X) is close to Y.

In the classical regression setting, the closeness of g(X) to Y is measured via the L2 risk, also called the mean squared error (MSE). In the MAPE regression context, the closeness of g(X) to Y is measured via the MAPE, and the aim of MAPE regressions is to find a model gMAPE such that:

gMAPE(x)=arg⁡ming∈𝒢𝔼[|g(X)−YY||X=x]

where 𝒢 is the class of models considered (e.g. linear models).

In practice

In practice gMAPE(x) can be estimated by the empirical risk minimization strategy, leading to

g^MAPE(x)=arg⁡ming∈𝒢∑i=1n|g(Xi)−YiYi|

From a practical point of view, the use of the MAPE as a quality function for regression model is equivalent to doing weighted mean absolute error (MAE) regression, also known as quantile regression. This property is trivial since

g^MAPE(x)=arg⁡ming∈𝒢∑i=1nω(Yi)|g(Xi)−Yi| with ω(Yi)=|1Yi|

As a consequence, the use of the MAPE is very easy in practice, for example using existing libraries for quantile regression allowing weights.

Consistency

The use of the MAPE as a loss function for regression analysis is feasible both on a practical point of view and on a theoretical one, since the existence of an optimal model and the consistency of the empirical risk minimization can be proved.

WMAPE

WMAPE (sometimes spelled wMAPE) stands for weighted mean absolute percentage error. It is a measure used to evaluate the performance of regression or forecasting models. It is a variant of MAPE in which the mean absolute percent errors is treated as a weighted arithmetic mean. Most commonly the absolute percent errors are weighted by the actuals (e.g. in case of sales forecasting, errors are weighted by sales volume). Effectively, this overcomes the 'infinite error' issue. Its formula is: wMAPE=∑i=1n(wi⋅|Ai−Fi||Ai|)∑i=1nwi=∑i=1n(|Ai|⋅|Ai−Fi||Ai|)∑i=1n|Ai|

Where wi is the weight, A is a vector of the actual data and F is the forecast or prediction. However, this effectively simplifies to a much simpler formula: wMAPE=∑i=1n|Ai−Fi|∑i=1n|Ai|

In some applications, custom weighting factors wi (such as unit price or cost) are applied to weight both the numerator and denominator. This generalized formulation is defined as:

wMAPE=∑i=1nwi|Ai−Fi|∑i=1nwi|Ai|

When wi=1 for all i, this formulation simplifies to standard volume-weighted MAPE (often abbreviated as WAPE).

Issues

Although the concept of MAPE sounds very simple and convincing, it has major drawbacks in practical application, and there are many studies on shortcomings and misleading results from MAPE.

To overcome these issues with MAPE, there are some other measures proposed in literature:

See also