From Surf Wiki (app.surf) — the open knowledge base
Mean absolute percentage error
Measure of prediction accuracy of a forecast
Measure of prediction accuracy of a forecast
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:
: \mbox{MAPE} = 100\frac{1}{n}\sum_{t=1}^n \left|\frac{A_t-F_t}{A_t}\right|
Where A**t is the actual value and F**t is the forecast value. Their difference is divided by the actual value A**t. 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 \mathbb{R}^d\times\mathbb{R}, and n i.i.d. copies (X_1, Y_1), ..., (X_n, Y_n) of (X,Y). Regression models aim at finding a good model for the pair, that is a measurable function g from \mathbb{R}^d to \mathbb{R} 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 g_\text{MAPE} such that:
g_\mathrm{MAPE}(x) = \arg\min_{g \in \mathcal{G}} \mathbb{E} \Biggl[ \left|\frac{g(X) - Y}{Y}\right| | X = x\Biggr]
where \mathcal{G} is the class of models considered (e.g. linear models).
In practice
In practice g_\text{MAPE}(x) can be estimated by the empirical risk minimization strategy, leading to
\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
\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.
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: \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 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: \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. Perhaps it would be more accurate to call this the double weighted MAPE (wwMAPE). Its formula is: \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|}
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.
- It cannot be used if there are zero or close-to-zero values (which sometimes happens, for example in demand data) because there would be a division by zero or values of MAPE tending to infinity.
- For forecasts which are too low the percentage error cannot exceed 100%, but for forecasts which are too high there is no upper limit to the percentage error.
- MAPE puts a heavier penalty on negative errors, A_t than on positive errors. As a consequence, when MAPE is used to compare the accuracy of prediction methods it is biased in that it will systematically select a method whose forecasts are too low. This little-known but serious issue can be overcome by using an accuracy measure based on the logarithm of the accuracy ratio (the ratio of the predicted to actual value), given by \log\left(\frac{\text{predicted}}{\text{actual}}\right) . This approach leads to superior statistical properties and also leads to predictions which can be interpreted in terms of the geometric mean.
- People often think the MAPE will be optimized at the median. But for example, a log normal has a median of e^\mu where as its MAPE is optimized at e^{\mu - \sigma^{2}}.
To overcome these issues with MAPE, there are some other measures proposed in literature:
- Mean Absolute Scaled Error (MASE)
- Symmetric Mean Absolute Percentage Error (sMAPE)
- Mean Directional Accuracy (MDA)
- Mean Arctangent Absolute Percentage Error (MAAPE): MAAPE can be considered a slope as an angle, while MAPE is a slope as a ratio.
References
References
- de Myttenaere, B Golden, B Le Grand, F Rossi (2015). "Mean absolute percentage error for regression models", Neurocomputing 2016 {{ArXiv. 1605.02541
- "Understanding Forecast Accuracy: MAPE, WAPE, WMAPE".
- "WMAPE: Weighted Mean Absolute Percentage Error".
- "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. [https://ssrn.com/abstract=2635088 archived preprint]
- 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]].
- 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]].
- (1 July 2016). "A new metric of absolute percentage error for intermittent demand forecasts". International Journal of Forecasting.
- 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]]
This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.
Ask Mako anything about Mean absolute percentage error — get instant answers, deeper analysis, and related topics.
Research with MakoFree with your Surf account
Create a free account to save articles, ask Mako questions, and organize your research.
Sign up freeThis content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.
Report