使用方式:
import numpy as np
from sklearn.model_selection import train_test_split
x = [1, 2, 3, 4]
y = [5, 6, 7, 8]
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
print(x_train,x_test)
輸出為:
[4, 2, 1] [3]
由此範例,可得知train_test_split會先對x和y做打亂的動作,再依據test_size參數,切train和test set。
沒有留言:
張貼留言