Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-228

Moving Average Baseline MSE

Problem

Compute the one-step-ahead MSE of a moving average baseline. For t >= window, forecast x[t] with the mean of the previous window values, and average the squared errors.

Return 0.0 if window is not positive or is at least the series length.

Hint

The moving average forecast trails a trend, which costs error on trending series.

Test cases

case 1
in: [[1,2,3,4,5],2]
expected: 2.25
case 2
in: [[1,1,1,1],2]
expected: 0
case 3
in: [[1,2,1,2,1,2],2]
expected: 0.25
case 4
in: [[5,5],2]
expected: 0
Starter codePython
def moving_average_baseline_mse(series, window):
    # Your code here
    pass

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