|
使用sklearn中的train_test_split方法进行4:1划分的时候,测试集准确率是不断上升的,,而使用Stratifiedkfold进行5折交叉验证的时候准确率很低,只有50-60%,且不断震荡使用train_test_split代码:
xtrain,xtest,ytrain,ytest =train_test_split(x,y,test_size=0.2,shuffle=True,stratified=y)
使用stratifiedKfold代码:
skf=StratifiedKFold(n_splits=5,shuffle=True).split(x,y)
for train_index,test_index in skf:
xtrain,xtest=x[train_index],x[test_index]
xtrain.index,xtest.index = range(len(xtrain)),range(len(xtest))
ytrain,ytest=y[train_index],y[test_index]
除此处数据集划分不同之外,其他所有地方都是一样,没有改变
已经困在这里好几天了,求问各位大佬
|
|