TimeSeriesDataFrame.train_test_split¶
- TimeSeriesDataFrame.train_test_split(prediction_length: int, end_index: int | None = None, suffix: str | None = None) Tuple[TimeSeriesDataFrame, TimeSeriesDataFrame][source]¶
- Generate a train/test split from the given dataset. This method can be used to generate splits for multi-window backtesting. - Parameters:
- prediction_length (int) – Number of time steps in a single evaluation window. 
- end_index (int, optional) – If given, all time series will be shortened up to - end_idxbefore the train/test splitting. In other words, test data will include the slice- [:end_index]of each time series, and train data will include the slice- [:end_index - prediction_length].
- suffix (str, optional) – Suffix appended to all entries in the - item_idindex level.
 
- Returns:
- train_data (TimeSeriesDataFrame) – Train portion of the data. Contains the slice - [:-prediction_length]of each time series in- test_data.
- test_data (TimeSeriesDataFrame) – Test portion of the data. Contains the slice - [:end_idx]of each time series in the original dataset.