You are training a pneumonia detector on 5,000 chest X-rays collected from 500 patients (10 scans per patient). Why does standard or stratified -fold cross-validation overestimate test accuracy, and how does group -fold fix it?
ML systems and evaluation, Cross-validation
Level L2 Elementary. Length Short. Nature Th Theoretical.
What's being asked
Whether you recognise group-level dependence across samples and match the validation split to deployment.
Key idea
If scans from the same patient appear in both training and validation folds, the model can memorise patient-specific anatomy, scanner marks or baseline traits rather than disease features; group -fold keeps every group (all scans of a patient) strictly in one fold.
Steps
- Identify the leak: multiple scans from the same patient are strongly correlated, sharing body shape, implants, hospital background and patient history.
- Explain the failure of ordinary or stratified -fold: splitting at the scan level lets the model recognise a patient from training folds and predict their diagnosis in the validation fold, inflating accuracy.
- Describe group -fold: assign each patient ID to exactly one fold so training and validation patients are disjoint, matching deployment on unseen patients (use stratified group -fold if classes are also imbalanced).
Common mistakes
- Splitting randomly by image or recording when groups exist in medical data, user click logs, or video frames from the same clip.
- Using group -fold without checking group sizes; if one hospital or patient has half the data, folds become unbalanced, because a group is never split. Stratified group -fold balances the class ratios, but it cannot fix this.
How long your answer should be
3–5 sentences.
Last checked on 4 December 2026.
Read this
Previous in ML systems and evaluation: A search engine returns 4 results for three queries with binary relevance , and , where 1 means relevant and each query has exactly 2 relevant documents in the corpus. What are MRR and MAP, and when would you prefer each?
Next in ML systems and evaluation: An online A/B test configured for a 50/50 split logs 50,800 users in control and 49,200 in treatment out of 100,000 total. What does a goodness-of-fit test at (critical value ) show about sample ratio mismatch (SRM), and why must metric analysis stop if SRM fails?