Valueerror While Using Scikit Learn. Number Of Features Of Model Don't Match That Of Input
I am working on a classification problem using RandomForestClassifier. In the code I'm splitting the dataset into a train and test data for making predictions. Here's the code: fr
Solution 1:
It looks like you are using a_test
directly, without stripping out the output feature.
The model is confused because it expects only 1434 input features but you are feeding it 1434 features along with the output feature.
You can fix this by doing the same thing with test
that you did with train.
test = [x[1:] for x in a_test]
Then use test
on the following line:
predicted_probs = [[index + 1, x[1]]for index, x in enumerate(rf.predict_proba(test))]
Post a Comment for "Valueerror While Using Scikit Learn. Number Of Features Of Model Don't Match That Of Input"