What does train_test_split(X, y, stratify=y) guarantee?
Correct answer
A. The training and test sets keep approximately the same class proportions as the full dataset
16 views
A. The training and test sets keep approximately the same class proportions as the full dataset
16 views
Stratified splitting makes each subset's class distribution match the input, which protects rare classes from being absent from a small holdout. Without it a 2 percent positive class can vanish from a 100-row test set. It raises a clear error if a class has fewer than two members, and it does not make the split reproducible, which still needs random_state.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is A? Ask here and get an explanation.