1from sklearn.model_selection import train_test_split
2X_train, X_test, y_train, y_test = train_test_split(
3 X, y, test_size=0.33, random_state=42)
1import numpy as np
2from sklearn.model_selection import train_test_split
3
4X, y = np.arange(10).reshape((5, 2)), range(5)
5
6X_train, X_test, y_train, y_test = train_test_split(
7 X, y, test_size=0.33, random_state=42)
8
9X_train
10# array([[4, 5],
11# [0, 1],
12# [6, 7]])
13
14y_train
15# [2, 0, 3]
16
17X_test
18# array([[2, 3],
19# [8, 9]])
20
21y_test
22# [1, 4]
1from sklearn.model_selection import train_test_split
2xTrain, xTest, yTrain, yTest = train_test_split(x, y, test_size = 0.2, random_state = 0)