When cv is left as None in cross_val_score for a classifier, which cross-validator is used?
Correct answer
C. StratifiedKFold with five splits, preserving class proportions in each fold
16 views
C. StratifiedKFold with five splits, preserving class proportions in each fold
16 views
Default cross-validation is five-fold, and for classifiers scikit-learn upgrades KFold to StratifiedKFold so each fold mirrors the overall class distribution. Stratification matters with imbalanced classes, where an unstratified split can yield a fold with almost no positives. Passing cv=5 explicitly gives the same behaviour, while passing cv=KFold(5) deliberately disables stratification.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.