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]
I printed out the train_index and test_index, they are array of indices.
What does this for loop mean? The train_index and test_index have different number of elements, how does iteration work?
Is this code equivalent to the below?
from sklearn.model_selection import StratifiedShuffleSplit
split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42)
train_index, test_index = split.split(housing, housing["income_cat"]):
strat_train_set = housing