Stratified Splits

A random split can leave more or fewer of one class in the test part than in the data, and stratify=y makes train_test_split keep each class's share the same in both parts, which you check with value_counts(normalize=True).

By

Updated

Cheat sheet: Stratified Splits
Category
Machine Learning
Level
Journeyman
Tags
ai, python, Stratified Split, Test Data, train_test_split(), value_counts()