Closed bingyanhu closed 5 years ago
@klarsen1
I think MAPE is strange for negative values. For example, if the truth is -5 and I predict 5, what's the MAPE? Is it 10/5? I guess my assumption is that, for market matching, you're typically matching on metrics like sales, counts, etc.
The purpose of this piece of code (mape_o_zeros) is actually to deal with MAPE when the counts hit 0.
I looked into the
mape_no_zeros <- function(test, ref){ d <- cbind.data.frame(test, ref) d <- subset(d, abs(test)>0) return(mean(abs(lm(test ~ ref, data=d)$residuals)/d$test)) }
If the test contains negative values, for each training data pair, would we calculating its absolute deviation as |ref/test|, instead of |ref|/test?
return(mean(abs(lm(test ~ ref, data=d)$residuals/d$test)))
https://en.wikipedia.org/wiki/Mean_absolute_percentage_error