TSCKfoldSeries#

class datafold.pcfold.TSCKfoldSeries(n_splits=3, shuffle=False, random_state=None)[source]#

Bases: TSCCrossValidationSplit

K-fold splits on entire time series.

Both the training and the test set consist of time series in its original length. Therefore, to perform the split, the time series collection must consist of multiple time series.

Parameters:
  • n_splits – The number of splits.

  • shuffle (bool) – If True, the time series are shuffled.

  • random_state (Optional[int]) – Use fixed seed if shuffle=True.

Methods Summary

get_n_splits([X, y, groups])

Number of splits, which are also the number of cross-validation iterations.

split(X[, y, groups])

Yields k-folds of training and test indices of time series collection.

Methods Documentation

get_n_splits(X=None, y=None, groups=None)[source]#

Number of splits, which are also the number of cross-validation iterations.

All parameter are ignored to align with scikit-learn’s function.

Parameters:
  • X – ignored

  • y – ignored

  • groups – ignored

Return type:

int

split(X, y=None, groups=None)[source]#

Yields k-folds of training and test indices of time series collection.

Parameters:
  • X (TSCDataFrame) – The time series collection to split.

  • y (None) – ignored

  • groups (None) – ignored

Yields:
  • numpy.ndarray – train indices

  • numpy.ndarray – test indices

Raises:

NotImplementedError – If time series have not equal length.

Return type:

Generator[tuple[ndarray, ndarray], None, None]