January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to split the dataset into training and test sets.
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y, random_state=42)
y_train.value_counts(normalize=True)y_test.value_counts(normalize=True) ...
Read now
Unlock full access