mne_rsa.create_folds#

mne_rsa.create_folds(X, y=None, n_folds=None)[source]#

Group individual items into folds suitable for cross-validation.

The y list should contain an integer label for each item in X. Repetitions of the same item have the same integer label. Repeated items are distributed evenly across the folds, and averaged within a fold.

Parameters
Xndarray, shape (n_items, …)

For each item, all the features. The first dimension are the items and all other dimensions will be flattened and treated as features.

yndarray of int, shape (n_items,) | None

For each item, a number indicating the class to which the item belongs. When None, each item is assumed to belong to a different class. Defaults to None.

n_foldsint | sklearn.BaseCrossValidator | None

Number of cross-validation folds to use when computing the distance metric. Folds are created based on the y parameter. Specify None to use the maximum number of folds possible, given the data. Alternatively, you can pass a Scikit-Learn cross validator object (e.g. sklearn.model_selection.KFold) to assert fine-grained control over how folds are created. Defaults to None.

Returns
foldsndarray, shape (n_folds, n_items, …)

The folded data.