Back to models
Splitter

SlidingGreedySplitter

Splitter that combines sliding window with greedy splitting.

Takes integers or floats train_size and test_size that define the number of steps included in the train and test sets of each fold. If float values are provided, they are interpreted as proportions of the total length of the time series. If the data contains multiple instances, sizes are _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.

Quickstart

python
from sktime.split.slidinggreedy import SlidingGreedySplitter

estimator = SlidingGreedySplitter(train_size: int | float, test_size: int | float, folds: int=5, step_length: int | None=None)

Parameters(4)

train_sizeint or float
If int: the number of steps included in the train set of each fold.

Formally, steps are consecutive iloc indices.

test_sizeint or float
If int: the number of steps included in the test set of each fold.

Formally, steps are consecutive iloc indices.

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 SlidingGreedySplitter
>>> ts = np. arange (10)
>>> splitter = SlidingGreedySplitter (train_size = 4, test_size = 2, folds = 2)
>>> list (splitter. split (ts)) [(array([2, 3, 4, 5]), array([6, 7])), (array([4, 5, 6, 7]), array([8, 9])) ]