Receiving KeyError: “None of [Int64Index([ … dtype='int64', length=1323)] are in the [columns]”

后端 未结 1 989
攒了一身酷
攒了一身酷 2021-02-14 09:32

SUMMARY

When feeding test and train data into a ROC curve plot, I receive the following error:

KeyError: \"None of [Int64Index([ 0, 1, 2

相关标签:
1条回答
  • 2021-02-14 10:12

    in this piece of code train, test are arrays of indices, while you using it as a columns when selection from DataFrame:

    for train, test in kf.split(X, Y):
        probas_ = model.fit(X[train], Y[train]).predict_proba(X[test])
    

    you should use iloc instead:

        probas_ = model.fit(X.iloc[train], Y.iloc[train]).predict_proba(X.iloc[test])
    
    0 讨论(0)
提交回复
热议问题