reservoirpy.datasets.to_forecasting#
- reservoirpy.datasets.to_forecasting(timeseries, forecast=1, axis=0, test_size=None)[source]#
Split a timeseries for forecasting tasks.
Transform a timeseries \(X\) into a series of input values \(X_t\) and a series of output values \(X_{t+\mathrm{forecast}}\).
It is also possible to split the timeseries between training timesteps and testing timesteps.
- Parameters:
timeseries (np.ndarray) – Timeseries to split.
forecast (int, optional) – Number of time lag steps between the timeseries \(X_t\) and the timeseries \(X_{t+\mathrm{forecast}}\), by default 1, i.e. returns two timeseries with a time difference of 1 timesteps.
axis (int, optional) – Time axis of the timeseries, by default 0
test_size (int or float, optional) – If set, will also split the timeseries into a training phase and a testing phase of
test_size
timesteps. Can also be specified as a float ratio, by default None
- Returns:
\(X_t\) and \(X_{t+\mathrm{forecast}}\).
If
test_size
is specified, will return: \(X_t\), \(X_t^{test}\), \(X_{t+\mathrm{forecast}}\), \(X_{t+\mathrm{forecast}}^{test}\).The size of the returned timeseries is therefore the size of \(X\) minus the forecasting length
forecast
.- Return type:
- Raises:
ValueError – If
test_size
is a float, it must be in [0, 1[.