What is k-fold cross-validation and when do you use stratified or grouped folds?
mediumAnswer
- Split the data into k folds; train on k-1 and validate on the held-out fold, then average.
- Use stratified k-fold for classification (preserves class ratios per fold).
- Use grouped k-fold when rows share an identity (same user, same patient) so the group never appears in both train and validation, preventing leakage.
- Use time-series split for temporal data.
Check yourself — multiple choice
- Stratified k-fold is only for regression
- Grouped k-fold prevents leakage when rows share an entity
- Time-series data should use random k-fold
- k-fold requires at least 100 folds
Grouped k-fold keeps all rows of the same entity in one fold, preventing subject leakage.
#evaluation#validation
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- What are the roles of the training, validation and test sets?
- What is the bias-variance tradeoff?
- How do you detect and fix overfitting?
- What does the IID assumption mean and when is it violated?
- What is the generalization gap and how do you shrink it?
- What is the out-of-bag (OOB) score in Random Forests?