temporal_train_test_split#

temporal_train_test_split(y: Series | DataFrame | ndarray | Index, X: DataFrame | None = None, test_size: int | float | None = None, train_size: int | float | None = None, fh: int | list | ndarray | Index | ForecastingHorizon | None = None) Tuple[Series, Series] | Tuple[Series, Series, DataFrame, DataFrame][source]#

Split arrays or matrices into sequential train and test subsets.

Creates train/test splits over endogenous arrays an optional exogenous arrays.

This is a wrapper of scikit-learn’s train_test_split that does not shuffle the data.

Parameters:
ypd.Series

Target series

Xpd.DataFrame, optional (default=None)

Exogenous data

test_sizefloat, int or None, optional (default=None)

If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the relative number of test samples. If None, the value is set to the complement of the train size. If train_size is also None, it will be set to 0.25.

train_sizefloat, int, or None, (default=None)

If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the train split. If int, represents the relative number of train samples. If None, the value is automatically set to the complement of the test size.

fhForecastingHorizon
Returns:
splittingtuple, length=2 * len(arrays)

List containing train-test split of y and X if given.

References