I have a dataset that looks like this
Im trying to run a 10-fold cross-validation on the set. However, Im encountering this error error - raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Int64Index([ 578, 579, 580, 581, 582, 583, 584, 585, 586, 587,\n ...\n 5770, 5771, 5772, 5773, 5774, 5775, 5776, 5777, 5778, 5779],\n dtype='int64', length=5202)] are in the [columns]"
How do I solve this?
CodePudding user response:
The variables train
and test
are row indices, so you will probably solve it by replacing the last row with
X_train, X_test, y_train, y_test = X.iloc[train], X.iloc[test], Y.iloc[train], Y.iloc[test]
(Please next time don't post your code as an image and report the whole error message.)