179 questions
No questions match those filters.
When does the wrong choice between Stratified K-Fold and Group K-Fold break a model in production?
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansStratified K-Fold and Group K-Fold get reached for interchangeably by candidates who haven’t hit the failure mode yet, but they solve genuinely different problems.
- Stratified K-Fold preserves the class ratio in every fold. It exists because a plain random split, on an imbalanced dataset, can by chance produce a fold with zero positive examples — at which point you literally cannot compute recall or precision for that fold at all.
- Group K-Fold keeps every row from the same entity — one user, one session, one patient — entirely inside a single fold, train or test, never split between them. It exists because rows from the same entity are correlated with each other in ways a model can exploit.
Where the wrong choice breaks production: a recommendation model trained with a plain random K-Fold split, where one user’s fifty movie ratings get scattered across both train and test. The model isn’t generalizing about taste in general — it’s partially memorizing that specific user’s pattern during training and then “predicting” the held-out half of their own ratings suspiciously well. Validation AUC looked great (0.78 in a real case); switching to Group K-Fold, grouped by user, dropped the honest validation number to 0.65 — which is what production actually delivered (0.64), because every production user is, by construction, someone the model has never partially seen before.
The standing question that prevents this, on any evaluation setup before locking in a CV strategy: is there any grouping in this data — user, session, device, patient — that should never be split across folds? If yes, Group K-Fold; if the concern is instead a rare positive class, Stratified K-Fold; and if both apply, a combined StratifiedGroupKFold. Getting this wrong doesn’t show up as an error — it shows up months later as a validation number that never matched reality.