When would you use stratified group k-fold instead of plain group k-fold?

Quick Overview

Asks when stratified group k-fold cross-validation is a better choice than plain group k-fold. Tests understanding of group leakage, class balance across folds, stable per-fold metrics with rare positives, and the limits of stratifying whole groups.

When would you use stratified group k-fold instead of plain group k-fold?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

When would you use stratified group k-fold instead of plain group k-fold? Both splitters keep every group (for example, all rows from one patient or one user) inside a single fold. Explain what the stratified version adds and when that difference matters. ```hint Look at one fold Think about what each splitter balances across folds, and what happens to a per-fold metric such as recall or AUC when a validation fold contains only a handful of positives. ``` ### What a Strong Answer Covers - What plain group k-fold guarantees and what it ignores. - What stratification adds and why it matters for per-fold metrics. - The data conditions under which the two splitters give very different folds. - The limits of stratifying while keeping groups intact. ### Follow-up Questions - You have only 4 positive patients and want 5 folds. What do you do? - How do you pass the groups correctly through a hyperparameter search in scikit-learn? - When would you pool out-of-fold predictions and compute one metric instead of averaging per-fold metrics? - How does the choice change when the groups are also ordered in time?

Overview: Asks when stratified group k-fold cross-validation is a better choice than plain group k-fold. Tests understanding of group leakage, class balance across folds, stable per-fold metrics with rare positives, and the limits of stratifying whole groups.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

When would you use stratified group k-fold instead of plain group k-fold?

Both splitters keep every group (for example, all rows from one patient or one user) inside a single fold. Explain what the stratified version adds and when that difference matters.

What a Strong Answer Covers Guidance

  • What plain group k-fold guarantees and what it ignores.
  • What stratification adds and why it matters for per-fold metrics.
  • The data conditions under which the two splitters give very different folds.
  • The limits of stratifying while keeping groups intact.

Follow-up Questions Guidance

  • You have only 4 positive patients and want 5 folds. What do you do?
  • How do you pass the groups correctly through a hyperparameter search in scikit-learn?
  • When would you pool out-of-fold predictions and compute one metric instead of averaging per-fold metrics?
  • How does the choice change when the groups are also ordered in time?