July 2019
Beginner to intermediate
740 pages
16h 52m
English
We made the high_quality column back at the beginning of this chapter, but remember that there was a large imbalance in the amount of red wines that were high_quality. So, when we split our data, we will stratify by that column for a stratified random sample to make sure that both the training and testing sets preserve the ratio of high-quality to low-quality wines in the data (roughly 14% are high quality):
>>> from sklearn.model_selection import train_test_split>>> red_y = red_wine.pop('high_quality')>>> red_X = red_wine.drop(columns='quality')>>> r_X_train, r_X_test, r_y_train, r_y_test = train_test_split(... red_X, red_y, test_size=0.1, random_state=0, stratify=red_y... )
Let's make a pipeline that will first ...
Read now
Unlock full access