这是代码:
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迭代器为您提供DataFrame的训练和验证对象的位置索引,而不是它们的非连续索引.您可以使用.iloc pandas方法访问您的火车和验证对象: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中返回错误的索引所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)