Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-357

Naive vs Seasonal Naive Selection

Problem

Choose the better in-sample baseline for a series by comparing mean squared errors. The naive method uses the previous observation and the seasonal naive method uses the observation one season of length m earlier.

Return the string seasonal-naive when its MSE is strictly smaller, otherwise return naive. Return naive when the seasonal method cannot be computed or the series has fewer than two observations.

Hint

Ties go to the simpler naive method.

Test cases

case 1
in: [[10,20,10,20],2]
expected: "seasonal-naive"
case 2
in: [[1,2,3,4,5],1]
expected: "naive"
case 3
in: [[1,3],5]
expected: "naive"
case 4
in: [[5],2]
expected: "naive"
case 5
in: [[1,2,3,1,2,3],3]
expected: "seasonal-naive"
Starter codePython
def choose_baseline(series, m):
    # Your code here
    pass

5 test cases · run your code against them in the editor