CH02: Use train_test_split instead of StratifiedShuffleSplit
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 25.6k
- Fork
- 12.7k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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!
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.