问题描述
嘿,在对时间序列进行预测之后,我获得了一个像这样的数据帧(df)(数字仅是示例):
Hy guys, after a process of forecasting of time series, I've obtained a data frame (df) that is like this (numbers are only examples):
fcast_mean | actual_values
12,5 | 12,3
1,1 | 0
24,3 | 22,7
29,6 | 30,4
... | ...
我知道,如果actual_value为零,则MAPE是无限的,这就是我的情况!我的问题是:在abs(actual_values - fcast$mean)/abs(actual_values)
等于Inf
的行(在本例中为第二行)中放入0而不是Inf在数学上是错误的吗?此更改对MAPE的计算有何后果?它不再是预测准确性的可靠指标吗?
I know that MAPE is infinite if actual_value is zero and this is my situation!My question is: Is it mathematically wrong to put 0 instead of Inf in the row (in this case the 2nd row) where abs(actual_values - fcast$mean)/abs(actual_values)
is equal to Inf
?What are the consequences of this change for the calculation of MAPE? It becomes no longer a reliable indicator for the accuracy of forecasting?
我对MAPE的R代码部分是:
My part of R code for the MAPE is:
x <- abs(df$actual_values-df$fcast_mean)/abs(df$actual_values)
x[is.infinite(x)] <- 0
MAPE <- (1/nrow(df$actual_values))*(sum(x))*100
推荐答案
您不能只将Inf
更改为0并期望结果有意义.无限MAPE是MAPE可能出现的问题之一.出现此问题时,请使用其他准确性度量方法.
You cannot just change Inf
to 0 and expect the results to make any sense. An infinite MAPE is one of the problems that can arise with MAPEs. Use alternative measures of accuracy when this problem arises.
MASE是一种替代方法(平均绝对标度误差),在此处中进行了描述.
MASE is one alternative (mean absolute scaled error), described here.
由于使用的是R,所以forecast
软件包中的accuracy
函数可能会有用.
Since you are using R, the accuracy
function from the forecast
package might be useful.
这篇关于预测精度-MAPE和零值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!