from __future__ import print_function
import numpy as np
from sklearn.model_selection import train_test_split
X, y = np.arange(10).reshape((5, 2)), range(5)
print(X)
# [[ 0 1]
# [ 2 3]
# [ 4 5]
# [ 6 7]
# [ 8 9]]
print(y)
# range(0, 5), [0, 1, 2, 3, 4]
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size = 0.4, random_state = 22)
print(X_train)
# [[6 7]
# [0 1]
# [8 9]]
print(y_train)
# [3, 0, 4]
print(X_test)
# [[2 3]
# [4 5]]
print(y_test)
# [1, 2]
1)sklearn学习之train_test_split
猜你喜欢
转载自blog.csdn.net/kelsel/article/details/84843258
今日推荐
周排行