LoslegenKostenlos loslegen

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!

Diese Übung ist Teil des Kurses

Forecasting Product Demand in R

Kurs anzeigen

Anleitung zur Übung

  • Convert the mean of your forecast (forecast_MET_t$mean) and validation data set (MET_t_valid) to numeric values and save them as for_MET_t and v_MET_t respectively.
  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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)
Code bearbeiten und ausführen