1. Home
  2. Data Science
  3. Scikit-learn
  4. StratifiedKFold is used with n_splits=5 on data where one…

Added 30 Nov -0001

StratifiedKFold is used with n_splits=5 on data where one class has only three members. What does scikit-learn do?

  1. It merges the smallest class into the largest one before splitting
  2. It warns, producing folds where that class is absent from some splits Correct answer
  3. It raises a ValueError, since each class needs at least n_splits rows
  4. It reduces n_splits automatically to the size of the smallest class

Correct answer

B. It warns, producing folds where that class is absent from some splits

50 views

MCQSEXAM

Explanation

StratifiedKFold tries to keep each class's proportion in every fold, but with fewer members than splits it can only warn and leave some folds without that class. The visible effect is a fold where a label is unseen, which breaks metrics that assume all labels are present. Very rare classes usually need a lower n_splits or a group-aware splitter instead.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? 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