Splitter
ExpandingWindowSplitter
Expanding window splitter.
Split time series repeatedly into an growing training set and a fixed-size test set.
Test window is defined by forecasting horizons relative to the end of the training window. It will contain as many indices as there are forecasting horizons provided to the fh argument. For a forecasating horizon \((h_1,\ldots,h_H)\), the training window will consist of the indices \((k_n+h_1,\ldots,k_n+h_H)\).
For example for initial_window = 5, step_length = 1 and fh = [1, 2, 3] here is a representation of the folds:
|-----------------------|
| * * * * * x x x - - - |
| * * * * * * x x x - - |
| * * * * * * * x x x - |
| * * * * * * * * x x x |
* = training fold.
x = test fold.
Schnellstart
python
from sktime.split.expandingwindow import ExpandingWindowSplitter
estimator = ExpandingWindowSplitter(fh=1, initial_window: int | float | Timedelta | timedelta | timedelta64 | DateOffset=10, step_length: int | Timedelta | timedelta | timedelta64 | DateOffset=1)Parameter(3)
- fhint, list or np.array, optional (default=1)
- Forecasting horizon
- initial_windowint or timedelta or pd.DateOffset, optional (default=10)
- Window length of initial training fold. If =0, initial training fold is empty.
- step_lengthint or timedelta or pd.DateOffset, optional (default=1)
- Step length between windows
Beispiele
>>> import numpy as np
>>> from sktime.split import ExpandingWindowSplitter
>>> ts = np. arange (10)
>>> splitter = ExpandingWindowSplitter (fh = [2, 4 ], initial_window = 5, step_length = 2)
>>> list (splitter. split (ts)) '[(array([0, 1, 2, 3, 4]), array([6, 8]))]'