This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stratified sampling | |
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] | |
for set_ in (strat_train_set, strat_test_set): | |
set_.drop('income_cat', axis=1, inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment