Back to models
Splitter

ExpandingSlidingWindowSplitter

Combined Expanding and Sliding Window Splitter.

This splitter starts as an expanding window splitter until a specified maximum window length is reached, then transitions to a sliding window splitter.

For example, with initial_window = 1, step_length = 1, fh = [1, 2],, and max_expanding_window_length = 8

|--------------------| | * x x - - - - - - -| Expanding (initial_window = 1) | * * x x - - - - - -| Expanding | * * * x x - - - - -| Expanding | * * * * x x - - - -| Expanding | * * * * * x x - - -| Expanding | - * * * * * x x - -| Sliding (switched) | - - * * * * * x x -| Sliding | - - - * * * * * x x| Sliding |--------------------|

0 1 2 3 4 5 6 7 8 9

^ |_ maximum expanding window size reached

* = training fold x = test fold - = unused observations

Quickstart

python
from sktime.split.expandingslidingwindow import ExpandingSlidingWindowSplitter

estimator = ExpandingSlidingWindowSplitter(fh=1, step_length: int | Timedelta | timedelta | timedelta64 | DateOffset=1, initial_window: int | float | Timedelta | timedelta | timedelta64 | DateOffset=10, max_expanding_window_length: int | float | Timedelta | timedelta | timedelta64 | DateOffset=inf)

Parameters(4)

fhint, list or np.array, optional (default=1)
Forecasting horizon
initial_windowint or timedelta or pd.DateOffset, optional (default=10)
Initial window length for the expanding window phase
step_lengthint or timedelta or pd.DateOffset, optional (default=1)
Step length between windows
max_expanding_window_lengthint, optional (default=float(‘inf’))
Maximum window length. If none is passed in, it will expanding indefinitely.

Examples

>>> import numpy as np
>>> from sktime.split import ExpandingSlidingWindowSplitter
>>> ts = np. arange (10)
>>> splitter = ExpandingSlidingWindowSplitter (
... fh = [1, 2 ],
... step_length = 3,
... initial_window = 1,
... max_expanding_window_length = 5,
... )
>>> list (splitter. split (ts)) [(array([0]), array([1, 2])), (array([0, 1]), array([2, 3])), (array([0, 1, 2]), array([3, 4])), (array([0, 1, 2, 3]), array([4, 5])), (array([0, 1, 2, 3, 4]), array([5, 6])), (array([1, 2, 3, 4, 5]), array([6, 7])), (array([2, 3, 4, 5, 6]), array([7, 8])), (array([3, 4, 5, 6, 7]), array([8, 9]))]
>>> import numpy as np
>>> from sktime.split import ExpandingSlidingWindowSplitter
>>> ts = np. arange (10)
>>> splitter = ExpandingSlidingWindowSplitter (
... fh = [1, 2 ],
... step_length = 3,
... initial_window = 2,
... max_expanding_window_length = 5,
... )
>>> list (splitter. split (ts)) [(array([0, 1]), array([2, 3])), (array([0, 1, 2, 3, 4]), array([5, 6])), (array([3, 4, 5, 6, 7]), array([8, 9]))]