temporal_train_test_split#

temporal_train_test_split(y: Union[pandas.core.series.Series, pandas.core.frame.DataFrame, numpy.ndarray, pandas.core.indexes.base.Index], X: Optional[pandas.core.frame.DataFrame] = None, test_size: Optional[Union[float, int]] = None, train_size: Optional[Union[float, int]] = None, fh: Optional[Union[int, list, numpy.ndarray, pandas.core.indexes.base.Index, sktime.forecasting.base._fh.ForecastingHorizon]] = None) Union[Tuple[pandas.core.series.Series, pandas.core.series.Series], Tuple[pandas.core.series.Series, pandas.core.series.Series, pandas.core.frame.DataFrame, pandas.core.frame.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

1

adapted from https://github.com/alkaline-ml/pmdarima/