The error is in PermutationImportance.fit when using cv=KFold or some other sklearn splitter.
sklearn splitters return the location indexes (i.e. iloc) of the rows, whereas PermutationImportance.fitis treating these as label indexes (i.e. loc).
This only gives the correct result when the index labels are the same as the index locations (e.g. when you have the default RangeIndex). If the dataframe has any other index, this will use the wrong splits or create a KeyError.
The error is in
PermutationImportance.fit
when usingcv=KFold
or some other sklearn splitter.sklearn splitters return the location indexes (i.e.
iloc
) of the rows, whereasPermutationImportance.fit
is treating these as label indexes (i.e.loc
).This only gives the correct result when the index labels are the same as the index locations (e.g. when you have the default RangeIndex). If the dataframe has any other index, this will use the wrong splits or create a KeyError.