All problems
Seasonal Naive MAE
Problem
Compute the in-sample mean absolute error of the seasonal naive method with period m. The error at time t is |x[t] - x[t-m]|, averaged over every t that has a full season of history.
Return 0.0 when m is not positive or when the series is not longer than one season.
Hint
There are n - m seasonal naive errors in a series of length n.
Test cases
case 1
in: [[1,5,2,6,3,7],2]
expected: 1
case 2
in: [[2,4,2,4],2]
expected: 0
case 3
in: [[1,2,3],5]
expected: 0
case 4
in: [[5,7,9],1]
expected: 2
Starter codePython
def seasonal_naive_mae(series, m):
# Your code here
pass4 test cases · run your code against them in the editor