python 把数据分成训练集和测试集

from sklearn.model_selection import train_test_split
import pandas as pd

f1=pd.read_excel('aaa.xlsx')

f1.columns
#Index(['X', 'Y'], dtype='object')

X_train,X_test,y_train,y_test = train_test_split(X,Y,test_size=0.3)

X_train: 训练集X
y_train: 训练集Y
X_test:测试集X
y_test:测试集Y
train_test_split:切割样本
test_size=0.3:选取样本30%作为测试集的数量

猜你喜欢

转载自blog.csdn.net/weixin_42342968/article/details/83538676
今日推荐