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
ylist should contain an integer label for each item inX. 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, [n_classes]) | None
For each item, a number indicating the class to which the item belongs. Alternatively, for each item, a one-hot encoded row vector incidating the class to which the item belongs. When
None, each item is assumed to belong to a different class. Defaults toNone.- n_foldsint | sklearn.BaseCrossValidator | None
Number of cross-validation folds to use when computing the distance metric. Folds are created based on the
yparameter. SpecifyNoneto 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 toNone.
- Returns:
- foldsndarray, shape (n_folds, n_items, …)
The folded data.