24.20 Stratification, small strata, and design preservation
resampling.stratify_by preserves specified study-level columns in resamples. Use it when study, treatment arm, region, or population affects selection opportunity. minimum_subjects_per_stratum defaults to 10 and protects against partitions that cannot support learner fitting.
Stratification should reflect the data-generating design, not be added after a covariate becomes unstable. Too many crossed strata create tiny cells and deterministic splits. Review counts, covariance support, and whether each category/feature remains estimable within units.
When a covariate is confounded with a stratum, no resampling strategy can identify separate effects without overlap. Report that design limitation and consider external information or a different estimand.
Common mistakes
- Stratifying by every available column.
- Ignoring small crossed cells.
- Using stratification to conceal study confounding.
- Allowing missing stratum values silently.
- Comparing stratified and unstratified probabilities as equivalent.
Checklist
- Prespecify design-relevant strata.
- Tabulate subject counts and feature support.
- Respect minimum size requirements.
- Review confounding and overlap.
- Report stratification in every stability result.
Further reading
Continue to learner overview and Chapter 21's stratification discussion.