A classification dataset has 5% positives. Which cross-validation variant keeps class proportions similar in each fold?
- Exam domain
- Machine Learning With RAPIDS16% of the exam
- Difficulty
- Medium
- In this mock
- 8 questions on this domainPractise this domain
Why the exam asks this
Machine Learning With RAPIDS (16% of the exam)
Objective in the exam guide: Cross-validation methods
Cross-validation methods are named.
Why B is the answer
Stratified k-fold
Stratified k-fold keeps the class ratio in each fold, so every fold has positives to evaluate on.
Remember: Stratified k-fold for imbalanced classes.
How it works
Cross-validation variants include k-fold, stratified k-fold and time-series splits.
In detail
- Stratify for imbalanced labels.
- Use time-series splits for temporal data.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Time-series splitWrongMost tempting
Time-series splits are for ordered data.
Why it tempts: Time-series split is also a CV variant, but for ordered data.
B. Stratified k-foldRight
Stratified k-fold for imbalanced classes.
C. Plain k-fold on sorted dataWrong
Sorted folds can contain no positives.
D. Leave-one-out on a random subsetWrong
Leave-one-out on a subset is noisy.
Use case
An illustrative scenario, not a real incident.
Illustrative: stratified 5-fold keeps about 5% positives in every fold.
See it in different ways
flowchart LR S0["Group rows by class"] --> S1["Spread each class across folds"] --> S2["Train on K-1 folds"] --> S3["Test on one"] --> S4["Repeat"]
How to read this chart
- Read it in order: Group rows by class, then Spread each class across folds, then Train on K-1 folds, then Test on one, then Repeat.
flowchart TD
Q{"Data type?"}
Q -->|"Imbalanced labels"| A0["Stratified k-fold"]
Q -->|"Time-ordered"| A1["Time-series split"]
Q -->|"Balanced"| A2["k-fold"]How to read this chart
- At "Data type?": if "Imbalanced labels", go to "Stratified k-fold"; if "Time-ordered", go to "Time-series split"; if "Balanced", go to "k-fold".