引入
from sklearn.model_selection import train_test_split
分割(原数据是一个打他frame,先进行切片操作,分开数据和标签)
data_X = data.iloc[:,1:] data_Y = data.iloc[:,0] rate_test = 0.2 # 测试集比例 x_train, x_test, y_train, y_test = train_test_split(data_X, data_Y, test_size= rate_test)