找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 524|回复: 0

[求助] 为什么sklearn使用交叉验证准确率要低且震荡很大?

1

主题

1

帖子

1

积分

贫民

积分
1
Tawl 发表于 2022-3-20 12:51:01 | 显示全部楼层 |阅读模式
使用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]

除此处数据集划分不同之外,其他所有地方都是一样,没有改变


已经困在这里好几天了,求问各位大佬
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表