train_test_splitに関する調査[sklearn]
7月 26, 2020
from sklearn.model_selection import train_test_split
X = [1, 2, 3, 4, 5]
y = [10, 20, 30, 40, 50]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=7)
print("X_train:", X_train)
print("X_test:", X_test)
print("y_train:", y_train)
print("y_test:", y_test)
z = [100, 200, 300, 400, 500]
z_train, z_test = train_test_split(z, test_size=0.2, random_state=7)
print("z_train:", z_train)
print("z_test:", z_test)
>> X_train: [4, 3, 2, 5]
>> X_test: [1]
>> y_train: [40, 30, 20, 50]
>> y_test: [10]
>> z_train: [300, 200, 100, 400]
>> z_test: [500]
関連記事
ディスカッション
コメント一覧
まだ、コメントがありません