1. Home
  2. Data Science
  3. Scikit-learn
  4. When cv is left as None in cross_val_score for a…

Added 30 Nov -0001

When cv is left as None in cross_val_score for a classifier, which cross-validator is used?

  1. LeaveOneOut, giving one fold per sample and a very large number of separate fits
  2. ShuffleSplit with a fixed random seed and a single random shuffle per call
  3. StratifiedKFold with five splits, preserving class proportions in each fold Correct answer
  4. Plain KFold with ten splits, ignoring the class labels of the samples entirely

Correct answer

C. StratifiedKFold with five splits, preserving class proportions in each fold

16 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs