grouped-cross-validation · shipping · also group-wise cross-validation, group-aware cross-validation

Grouped cross-validation

Grouped cross-validation evaluates a predictor using splits that keep all observations from each specified group together in either training or testing within a split.

Related Observatory article: Read on hesela.com

Grouped data breaks the i.i.d. assumption when samples share a source, such as several samples from each patient. GroupKFold keeps a group out of training whenever it is in a test fold, and its test folds form a complete partition of the data. [2] Its default is 5 folds, at least 2 are required and the number of distinct groups must be at least the number of folds. [1]

Grouping by physical drive tests unseen drives and grouping by site tests unseen sites, which are different generalization questions. StratifiedGroupKFold also tries to keep class proportions, LeaveOneGroupOut holds out one group per split and GroupShuffleSplit draws independent random group splits. [2]

Kapoor and Narayanan list non-independence between training and test samples as a leakage type, for example different observations of the same patient on both sides of the split. Their survey found leakage-related errors reported in 17 fields, affecting 329 papers. [3]

Relations

related
Temporal validation, Prediction horizon, Class prevalence, S.M.A.R.T., False positive rate

Advantages

  • Estimates performance on groups absent from training, which a sample-level split overstates when samples within a group are dependent. [3, 2]

Limitations

  • Choose groups for the deployment question. Grouping does not prevent future information or globally fitted preprocessing from entering training. [2]
  • Fold sizes can differ when groups are unequal, because shuffled GroupKFold balances the number of groups rather than samples. [2]

Citations

  1. scikit-learn: GroupKFold, non-overlapping groups and per-fold behavior. (accessed 2026-10-22)
  2. scikit-learn: cross-validation for grouped data, time series and training-only transformations. (accessed 2026-10-22)
  3. Sayash Kapoor and Arvind Narayanan. Leakage and the Reproducibility Crisis in ML-based Science. arXiv:2207.07048v1, 2022. (accessed 2026-10-22)
Sources & caveats
  • sklearn-validation is the scikit-learn user guide on cross-validation, re-read on 2026-10-22 in the section on grouped data.
  • sklearn-groupkfold is the scikit-learn GroupKFold API page, re-read on 2026-10-22, and is the source of the 5 and 2 fold values.
  • leakage is the 2022 arXiv preprint by Kapoor and Narayanan of Princeton University, read on 2026-10-22 in the abstract and leakage taxonomy.
  • The 17 fields and 329 papers come from leakage.

JSON: /data/terms/grouped-cross-validation.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Grouped cross-validation. Hesela. 2026-10-22. https://hesela.dev/terms/grouped-cross-validation/