Skip to content

Commit

Permalink
[MRG+1] Fix bug related to window_start index in RollingForecastCV. F…
Browse files Browse the repository at this point in the history
…ix the t… (#413)

* Fix bug related to window_start index in RollingForecastCV. Fix the test related to this class that also had a bug.

* Fix bug related to window_start index in RollingForecastCV. Fix the test related to this class that also had a bug.
  • Loading branch information
ad1729 committed Feb 24, 2021
1 parent 95b41f3 commit 1761972
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pmdarima/model_selection/_split.py
Expand Up @@ -243,14 +243,14 @@ def _iter_train_test_indices(self, y, X):
# guarantee that the forecasting horizon will not over-index the series
all_indices = np.arange(n_samples)
window_start = 0
window_end = initial
while True:
window_end = window_start + initial
if window_end + h > n_samples:
break

train_indices = all_indices[window_start: window_end]
test_indices = all_indices[window_end: window_end + h]
window_start += step
window_end += step

yield train_indices, test_indices

Expand Down
12 changes: 6 additions & 6 deletions pmdarima/model_selection/tests/test_split.py
Expand Up @@ -136,12 +136,12 @@ def test_rolling_forecast_cv_bad_splits():

expected = [
(np.arange(0, 90), np.array([90, 91, 92, 93])),
(np.arange(1, 91), np.array([91, 92, 93, 94])),
(np.arange(2, 92), np.array([92, 93, 94, 95])),
(np.arange(3, 93), np.array([93, 94, 95, 96])),
(np.arange(4, 94), np.array([94, 95, 96, 97])),
(np.arange(5, 95), np.array([95, 96, 97, 98])),
(np.arange(6, 96), np.array([96, 97, 98, 99])),
(np.arange(0, 91), np.array([91, 92, 93, 94])),
(np.arange(0, 92), np.array([92, 93, 94, 95])),
(np.arange(0, 93), np.array([93, 94, 95, 96])),
(np.arange(0, 94), np.array([94, 95, 96, 97])),
(np.arange(0, 95), np.array([95, 96, 97, 98])),
(np.arange(0, 96), np.array([96, 97, 98, 99])),
]

# should be 7
Expand Down

0 comments on commit 1761972

Please sign in to comment.