我的数据从数据集df中作为训练和测试进行拆分。 我可以拆分火车并以火车的X_train,Y_train和来自测试的X_test,Y_test进行测试吗?
示例代码:-
train, test = train_test_split(df, train_size=0.8, stratify=df.y_yes.values, random_state=5)
#Can I do the below splitting?
X_train, Y_train = train_test_split(train, random_state=5)
X_test, Y_test = train_test_split(test, random_state=5)
答案 0 :(得分:0)
我找不到解决方案,所以使用了正则表达式:-
X = df_clean[['previous', 'emp.var.rate', 'euribor3m', 'nr.employed',
'pdays_missing', 'poutcome_success' , 'poutcome_nonexistent','pdays_bet_5_15']]
y = df_clean['y_yes']
X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size = 0.2,
random_state=5)
print(X_train.shape)
print(X_test.shape)
print(Y_train.shape)
print(Y_test.shape)