ageron / ageron/handson-ml

CH02: Use train_test_split instead of StratifiedShuffleSplit

Abierto
#385 5 comentarios 17 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
25.6k
Forks
12.7k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

In CH02, the book uses StratifiedShuffleSplit to split data according to income category, maybe it's more user-friendly to use train_test_split
code from master:
```
from sklearn.model_selection import StratifiedShuffleSplit

split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42)
for train_index, test_index in split.split(housing, housing["income_cat"]):
strat_train_set = housing.loc[train_index]
strat_test_set = housing.loc[test_index]
```
updated version:
```
strat_train_set, strat_test_set = train_test_split(
housing, test_size=0.2, random_state=42, stratify=housing["income_cat"])
```
Thanks for the awesome book!

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.