Splitter
ExpandingGreedySplitter
Splitter that successively cuts test folds off the end of the series.
Takes an integer test_size that defines the number of steps included in the test set of each fold. The train set of each fold will contain all data before the test set. If the data contains multiple instances, test_size is _per instance_.
If no step_length is defined, the test sets (one for each fold) will be adjacent and disjoint, taken from the end of the dataset.
For example, with test_size=7 and folds=5, the test sets in total will cover the last 35 steps of the data with no overlap.
Quickstart
python
from sktime.split.expandinggreedy import ExpandingGreedySplitter
estimator = ExpandingGreedySplitter(test_size: int | float, folds: int=5, step_length: int | None=None)Parameters(3)
- test_sizeint or float
- If int: the number of steps included in the test set of each fold.
Formally, steps are consecutive
ilocindices.
- foldsint, default = 5
- The number of folds.
- step_lengthint, optional
The number of steps advanced for each fold. Defaults to
test_size.
Examples
>>> import numpy as np
>>> from sktime.split import ExpandingGreedySplitter
>>> ts = np. arange (10)
>>> splitter = ExpandingGreedySplitter (test_size = 3, folds = 2)
>>> list (splitter. split (ts)) [(array([0, 1, 2, 3]), array([4, 5, 6])), (array([0, 1, 2, 3, 4, 5, 6]), array([7, 8, 9])) ]