belong to class bthen stratified cross-validation ensures that in each fold of samples belong to class and of samples belong to class it is usually good idea to use stratified -fold cross-validation instead of -fold cross-validation to evaluate classifierbecause it results in more reliable estimates of generalization performance in the case of only of samples belonging to class busing standard -fold cross-validation it might easily happen that one fold only contains samples of class using this fold as test set would not be very informative about the overall performance of the classifier for regressionscikit-learn uses the standard -fold cross-validation by default it would be possible to also try to make each fold representative of the different values the regression target hasbut this is not commonly used strategy and would be surprising to most users more control over cross-validation we saw earlier that we can adjust the number of folds that are used in cross_val_score using the cv parameter howeverscikit-learn allows for much finer control over what happens during the splitting of the data by providing crossvalidation splitter as the cv parameter for most use casesthe defaults of -fold crossvalidation for regression and stratified -fold for classification work wellbut there are some cases where you might want to use different strategy sayfor examplewe want to use the standard -fold cross-validation on classification dataset to reproduce someone else' results to do thiswe first have to import the kfold splitter class from the model_selection module and instantiate it with the number of folds we want to usein[ ]from sklearn model_selection import kfold kfold kfold(n_splits= thenwe can pass the kfold splitter object as the cv parameter to cross_val_scorein[ ]print("cross-validation scores:\ {}formatcross_val_score(logregiris datairis targetcv=kfold))out[ ]cross-validation scores this waywe can verify that it is indeed really bad idea to use three-fold (nonstratifiedcross-validation on the iris dataset model evaluation and improvement