您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

sklearn kfold在python中返回错误的索引

5b51 2022/1/14 8:22:42 python 字数 1025 阅读 583 来源 www.jb51.cc/python

我在 python上的sklearn包中使用kfold函数在df(数据框)上使用不连续的行索引. 这是代码: kFold = KFold(n_splits=10, shuffle=True, random_state=None) for train_index, test_index in kFold.split(dfNARemove):... 我得到了一些在我的df中不存在的train_inde

概述

这是代码

kFold = KFold(n_splits=10,shuffle=True,random_state=None)
for train_index,test_index in kFold.split(dfNARemove):...

我得到了一些在我的df中不存在的train_index或test_index.

我能做什么?

kFold = KFold(n_splits=10,test_index in kFold.split(dfNARemove):
    train_data = dfNARemove.iloc[train_index]
    test_data = dfNARemove.iloc[test_index]

如果您想知道每个折叠上用于train_index和test_index的非连续索引,您可以执行以下操作:

non_continuous_train_index = dfNARemove.index[train_index]
non_continuous_test_index = dfNARemove.index[test_index]

总结

以上是编程之家为你收集整理的sklearn kfold在python中返回错误的索引全部内容,希望文章能够帮你解决sklearn kfold在python中返回错误的索引所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶