Forecast Errors: MAPE, sMAPE and MASE

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 19. Everything before it counts as cleared.

Implement three forecast accuracy metrics (as percentages for the first two):

  • mape(y, f) = 100n∑∣y−fy∣\frac{100}{n}\sum\left|\frac{y - f}{y}\right|, skipping points where y=0y = 0
  • smape(y, f) = 100n∑∣y−f∣(∣y∣+∣f∣)/2\frac{100}{n}\sum\frac{|y - f|}{(|y| + |f|)/2}, counting a term as 0 when both are 0
  • mase(y, f, y_train, m=1) = MAE of the forecast divided by the in-sample MAE of the seasonal naive forecast on y_train (lag m)
#forecasting#metrics2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Forecast Errors: MAPE, sMAPE and MASE · TechGradify