Part 03 / Topic 4 of 6
Train, validation and test splits
- Training set — the model learns from it.
- Validation set — you choose between models/settings with it.
- Test set — touched once, at the end, for the honest final number.
stratify=y keeps the class proportions equal across splits — with 29.9% churn overall, both splits stay at ~30% (the run above shows 0.299 / 0.300). Without it, a small split can end up with a noticeably different rate, and every metric shifts with it.
🔍 Going deeper: with little data, replace the fixed validation set with cross-validation (Part 6) — every row takes a turn validating. The test set still stays untouched until the end.
🧪 Quick quiz
- What does
stratify=ydo intrain_test_split?
Show the answer
Keeps the class proportions the same in train and test — verified above: churn rate 0.299 in train, 0.300 in test.
Done here? The practice set for Part 3 — 4 exercises with solutions — is on the part page.