SingleWindowSplitter#

class SingleWindowSplitter(fh: Union[int, list, numpy.ndarray, pandas.core.indexes.base.Index, sktime.forecasting.base._fh.ForecastingHorizon], window_length: Optional[Union[int, float, pandas._libs.tslibs.timedeltas.Timedelta, datetime.timedelta, numpy.timedelta64, pandas._libs.tslibs.offsets.DateOffset]] = None)[source]#

Single window splitter.

Split time series once into a training and test set. See more details on what to expect from this splitter in BaseSplitter.

Parameters
fhint, list or np.array

Forecasting horizon

window_lengthint or timedelta or pd.DateOffset

Window length

Methods

get_cutoffs([y])

Return the cutoff points in .iloc[] context.

get_fh()

Return the forecasting horizon.

get_n_splits([y])

Return the number of splits.

split(y)

Split y into training and test windows.

get_n_splits(y: Optional[Union[pandas.core.series.Series, pandas.core.frame.DataFrame, numpy.ndarray, pandas.core.indexes.base.Index]] = None) int[source]#

Return the number of splits.

Since this splitter returns a single train/test split, this number is trivially 1.

Parameters
ypd.Series or pd.Index, optional (default=None)

Time series to split

Returns
n_splitsint

The number of splits.

get_cutoffs(y: Optional[Union[pandas.core.series.Series, pandas.core.frame.DataFrame, numpy.ndarray, pandas.core.indexes.base.Index]] = None) numpy.ndarray[source]#

Return the cutoff points in .iloc[] context.

Since this splitter returns a single train/test split, this method returns a single one-dimensional array with the last train set index.

Parameters
ypd.Series or pd.Index, optional (default=None)

Time series to split

Returns
cutoffs1D np.ndarray of int

iloc location indices, in reference to y, of cutoff indices

get_fh() sktime.forecasting.base._fh.ForecastingHorizon[source]#

Return the forecasting horizon.

Returns
fhForecastingHorizon

The forecasting horizon

split(y: Union[pandas.core.series.Series, pandas.core.frame.DataFrame, numpy.ndarray, pandas.core.indexes.base.Index]) Generator[Tuple[numpy.ndarray, numpy.ndarray], None, None][source]#

Split y into training and test windows.

Parameters
ypd.Series or pd.Index

Time series to split

Yields
trainnp.ndarray

Training window indices

testnp.ndarray

Test window indices