gtime.model_selection.horizon_shift¶
-
gtime.model_selection.horizon_shift(time_series: pandas.core.frame.DataFrame, horizon: Union[int, List[int]] = 5) → pandas.core.frame.DataFrame¶ Perform a shift of the original
time_seriesfor each time step between 1 andhorizon.Parameters: - time_series : pd.DataFrame, shape (n_samples, n_features), required
The list of
TimeSeriesFeaturefrom which to compute the feature_extraction.- horizon : int, optional, default:
5 It represents how much into the future is necessary to predict. This corresponds to the number of shifts that are going to be performed on y.
Returns: - y : pd.DataFrame, shape (n_samples, horizon)
The shifted time series.
Examples
>>> import pandas as pd >>> from gtime.model_selection import horizon_shift >>> X = pd.DataFrame(range(0, 5), index=pd.date_range("2020-01-01", "2020-01-05")) >>> horizon_shift(X, horizon=2) y_1 y_2 2020-01-01 1.0 2.0 2020-01-02 2.0 3.0 2020-01-03 3.0 4.0 2020-01-04 4.0 NaN 2020-01-05 NaN NaN >>> horizon_shift(X, horizon=[2]) y_2 2020-01-01 2.0 2020-01-02 3.0 2020-01-03 4.0 2020-01-04 NaN 2020-01-05 NaN