November 2019
Intermediate to advanced
346 pages
9h 36m
English
The following steps demonstrate how to take a dataset, consisting of features X and labels y, and split these into a training and testing subset:
from sklearn.model_selection import train_test_splitimport pandas as pddf = pd.read_csv("north_korea_missile_test_database.csv")y = df["Missile Name"]X = df.drop("Missile Name", axis=1)
X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, random_state=31)