cv = model_selection.SlidingWindowForecastCV(window_size=100, step=24, h=1)
// store the residuals for each model
m1_residuals = []
m2_residuals = []
for train_window_indices, val_index in cv.split(train):
tr_fold = train[train_window_indices]
model1.fit(tr_fold)
model2.fit(tr_fold)
m1_residuals.append(train[val_index] - model1.predict(n_periods=1))
m2_residuals.append(train[val_index] - model2.predict(n_periods=1))
// make sure residuals are flat and compute RMSE
rmse = lambda arr: np.sqrt(np.average(utils.check_endog(arr) ** 2))
After Change
model2, train, scoring="mean_squared_error", cv=cv, verbose=2)
// Pick based on which has a lower mean error rate
m1_average_error = np.average(model1_cv_scores)
m2_average_error = np.average(model2_cv_scores)
errors = [m1_average_error, m2_average_error]
models = [model1, model2]