StratifiedKFold is used with n_splits=5 on data where one class has only three members. What does scikit-learn do?
Correct answer
B. It warns, producing folds where that class is absent from some splits
50 views
B. It warns, producing folds where that class is absent from some splits
50 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is B? Ask here and get an explanation.