BuildMidData / MLAuto-graded
Split a dataset reproducibly with balanced classes
Protecting a fair evaluation from mistakes that never crash: duplicated, dropped, or unevenly sampled records.Every model evaluation rests on an honest split of the data into a training set and a held-out test set. Get the split wrong and every metric downstream is a lie. Implementsplit(X, y, test_size, seed, stratify=True) returning four lists with each row still matched to its label — reproducible from the seed, and preserving class proportions when stratification is asked for.35 min
python
You're done when
- Every row appears exactly once across the two sets, with none lost or duplicated, even when the data contains identical rows.
- The same seed reproduces the same split exactly.
- With stratification on, each class appears in the test set in the expected proportion, with exact counts.
- The requested test proportion is honoured.
What it measures
Machine learningUnderstanding why stratification and reproducibility are prerequisites for a trustworthy evaluation.
Data preparation and preprocessingPartitioning data without losing or duplicating rows, including when duplicate payloads make identity ambiguous.
ReproducibilitySeeding so a result can be reproduced exactly, which is what makes a reported metric checkable.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
35 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo