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.
Consider a standard regression setting in which the data are fully described by a random pair Z = ( X , Y ) {\displaystyle Z=(X,Y)} with values in R d × R {\displaystyle \mathbb {R} ^{d}\times \mathbb {R} } , and n i.i.d. copies ( X 1 , Y 1 ) , . . . , ( X n , Y n ) {\displaystyle (X_{1},Y_{1}),...,(X_{n},Y_{n})} of ( X , Y ) {\displaystyle (X,Y)} . Regression models aim at finding a good model for the pair, that is a measurable function g from R d {\displaystyle \mathbb {R} ^{d}} to R {\displaystyle \mathbb {R} } such that g ( X ) {\displaystyle g(X)} is close to Y.
In the classical regression setting, the closeness of g ( X ) {\displaystyle g(X)} to Y is measured via the L2 risk, also called the mean squared error (MSE). In the MAPE regression context,1 the closeness of g ( X ) {\displaystyle g(X)} to Y is measured via the MAPE, and the aim of MAPE regressions is to find a model g MAPE {\displaystyle g_{\text{MAPE}}} such that:
g M A P E ( x ) = arg min g ∈ G E [ | g ( X ) − Y Y | | X = x ] {\displaystyle g_{\mathrm {MAPE} }(x)=\arg \min _{g\in {\mathcal {G}}}\mathbb {E} {\Biggl [}\left|{\frac {g(X)-Y}{Y}}\right||X=x{\Biggr ]}}
where G {\displaystyle {\mathcal {G}}} is the class of models considered (e.g. linear models).
In practice
In practice g MAPE ( x ) {\displaystyle g_{\text{MAPE}}(x)} can be estimated by the empirical risk minimization strategy, leading to
g ^ MAPE ( x ) = arg min g ∈ G ∑ i = 1 n | g ( X i ) − Y i Y i | {\displaystyle {\widehat {g}}_{\text{MAPE}}(x)=\arg \min _{g\in {\mathcal {G}}}\sum _{i=1}^{n}\left|{\frac {g(X_{i})-Y_{i}}{Y_{i}}}\right|}
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 min g ∈ G ∑ i = 1 n ω ( Y i ) | g ( X i ) − Y i | with ω ( Y i ) = | 1 Y i | {\displaystyle {\widehat {g}}_{\text{MAPE}}(x)=\arg \min _{g\in {\mathcal {G}}}\sum _{i=1}^{n}\omega (Y_{i})\left|g(X_{i})-Y_{i}\right|{\mbox{ with }}\omega (Y_{i})=\left|{\frac {1}{Y_{i}}}\right|}
As a consequence, the use of the MAPE is very easy in practice, for example using existing libraries for quantile regression allowing weights.
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.2
WMAPE (sometimes spelled wMAPE) stands for weighted mean absolute percentage error.3 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).4 Effectively, this overcomes the 'infinite error' issue.5 Its formula is:6 wMAPE = ∑ i = 1 n ( w i ⋅ | A i − F i | | A i | ) ∑ i = 1 n w i = ∑ i = 1 n ( | A i | ⋅ | A i − F i | | A i | ) ∑ i = 1 n | A i | {\displaystyle {\mbox{wMAPE}}={\frac {\displaystyle \sum _{i=1}^{n}\left(w_{i}\cdot {\tfrac {\left|A_{i}-F_{i}\right|}{|A_{i}|}}\right)}{\displaystyle \sum _{i=1}^{n}w_{i}}}={\frac {\displaystyle \sum _{i=1}^{n}\left(|A_{i}|\cdot {\tfrac {\left|A_{i}-F_{i}\right|}{|A_{i}|}}\right)}{\displaystyle \sum _{i=1}^{n}\left|A_{i}\right|}}}
Where w i {\displaystyle w_{i}} is the weight, A {\displaystyle A} is a vector of the actual data and F {\displaystyle F} is the forecast or prediction. However, this effectively simplifies to a much simpler formula: wMAPE = ∑ i = 1 n | A i − F i | ∑ i = 1 n | A i | {\displaystyle {\mbox{wMAPE}}={\frac {\displaystyle \sum _{i=1}^{n}\left|A_{i}-F_{i}\right|}{\displaystyle \sum _{i=1}^{n}\left|A_{i}\right|}}}
Confusingly, sometimes when people refer to wMAPE they are talking about a different model in which the numerator and denominator of the wMAPE formula above are weighted again by another set of custom weights w i {\displaystyle w_{i}} . Perhaps it would be more accurate to call this the double weighted MAPE (wwMAPE). Its formula is: wwMAPE = ∑ i = 1 n w i | A i − F i | ∑ i = 1 n w i | A i | {\displaystyle {\mbox{wwMAPE}}={\frac {\displaystyle \sum _{i=1}^{n}w_{i}\left|A_{i}-F_{i}\right|}{\displaystyle \sum _{i=1}^{n}w_{i}\left|A_{i}\right|}}}
Although the concept of MAPE sounds very simple and convincing, it has major drawbacks in practical application,7 and there are many studies on shortcomings and misleading results from MAPE.89
To overcome these issues with MAPE, there are some other measures proposed in literature:
de Myttenaere, B Golden, B Le Grand, F Rossi (2015). "Mean absolute percentage error for regression models", Neurocomputing 2016 arXiv:1605.02541 /wiki/ArXiv_(identifier) ↩
"Understanding Forecast Accuracy: MAPE, WAPE, WMAPE". https://www.baeldung.com/cs/mape-vs-wape-vs-wmape ↩
"WMAPE: Weighted Mean Absolute Percentage Error". https://ibf.org/knowledge/glossary/weighted-mean-absolute-percentage-error-wmape-299 ↩
"Statistical Forecast Errors". https://blog.olivehorse.com/statistical-forecast-errors ↩
Tofallis (2015). "A Better Measure of Relative Prediction Accuracy for Model Selection and Model Estimation", Journal of the Operational Research Society, 66(8):1352-1362. archived preprint https://ssrn.com/abstract=2635088 ↩
Hyndman, Rob J., and Anne B. Koehler (2006). "Another look at measures of forecast accuracy." International Journal of Forecasting, 22(4):679-688 doi:10.1016/j.ijforecast.2006.03.001. //doi.org/10.1016/j.ijforecast.2006.03.001 ↩
Kim, Sungil and Heeyoung Kim (2016). "A new metric of absolute percentage error for intermittent demand forecasts." International Journal of Forecasting, 32(3):669-679 doi:10.1016/j.ijforecast.2015.12.003. //doi.org/10.1016/j.ijforecast.2015.12.003 ↩
Kim, Sungil; Kim, Heeyoung (1 July 2016). "A new metric of absolute percentage error for intermittent demand forecasts". International Journal of Forecasting. 32 (3): 669–679. doi:10.1016/j.ijforecast.2015.12.003. https://doi.org/10.1016%2Fj.ijforecast.2015.12.003 ↩
Makridakis, Spyros (1993) "Accuracy measures: theoretical and practical concerns." International Journal of Forecasting, 9(4):527-529 doi:10.1016/0169-2070(93)90079-3 //doi.org/10.1016/0169-2070(93)90079-3 ↩