一、KFold
K-Folds cross-validator
Provides train/test indices to split data in train/test sets. Split dataset into k consecutive folds
(without shuffling by default).
Each fold is then used once as a validation while the k - 1 remaining folds form the training set.
sklearn.model_selection.StratifiedKFold(n_splits=3, shuffle=False, random_state=None)
Methods
- get_n_splits([X, y, groups]): Returns the number of splitting iterations in the cross-validator
- split(X[, y, groups]): Generate indices to split data into training and test set.
StratifiedKFold
Stratified K-Folds cross-validator
Provides train/test indices to split data in train/test sets.
This cross-validation object is a variation of KFold that returns stratified folds. The folds are made by preserving the percentage of samples for each class.
sklearn.model_selection.StratifiedKFold(n_splits=3, shuffle=False, random_state=None)
Methods
- get_n_splits([X, y, groups]): Returns the number of splitting iterations in the cross-validator
- split(X, y[, groups]): Generate indices to split data into training and test set.