Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Chapter 2: Stratify #635

Open
Jeffresh opened this issue Aug 3, 2021 · 1 comment
Open

Chapter 2: Stratify #635

Jeffresh opened this issue Aug 3, 2021 · 1 comment
Assignees

Comments

@Jeffresh
Copy link

Jeffresh commented Aug 3, 2021

Why use StrafiedShuffleSplit, instead of train_test_split with attribute stratify?

X_train, X_test = train_test_split(housing.values, test_size=0.2, stratify=housing['income_cat'], random_state=42)

I think its more clear and pythonic that make folds and use a for statement for 1 iteration

@ageron ageron self-assigned this Aug 17, 2021
@ageron
Copy link
Owner

ageron commented Aug 17, 2021

Hi @Jeffresh ,
Thanks for this great suggestion. I wanted to show an example of how to use the splitter classes, but I think I should point out that there's an alternative (and simpler) way to stratify. I'll add a note in the book and the notebooks.
👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants