Calculating MAPE and MAE
You previously calculated the forecast for the metropolitan region total sales and stored it in the object forecast_MET_t. You also have your validation data set stored in the object MET_t_valid that covers the same first 22 weeks of 2017. Let's see how good your forecast is!
Este exercício faz parte do curso
Forecasting Product Demand in R
Instruções do exercício
- Convert the mean of your forecast (
forecast_MET_t$mean) and validation data set (MET_t_valid) to numeric values and save them asfor_MET_tandv_MET_trespectively. - Calculate the MAE of your forecast. Remember, this is the average of the absolute difference between the forecast and the true validation values.
- Calculate the MAPE of your forecast. This takes the same difference as the MAE, but divides it by the true validation values.
- Print both the MAE and MAPE.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Convert to numeric for ease
for_MET_t <- as.numeric(___)
v_MET_t <- as.numeric(___)
# Calculate the MAE
MAE <- mean(abs(___ - ___))
# Calculate the MAPE
MAPE <- 100*mean(abs((for_MET_t - v_MET_t)/___))
# Print to see how good your forecast is!
print(MAE)
print(MAPE)