Number Of Features Of The Model Must Match The Input. Model N_features Is 40 And Input N_features Is 38
i am getting this error.please give me any suggestion to resolve it.here is my code.i am taking traing data from train.csv and testing data from another file test.csv.i am new to m
Solution 1:
There are multiple problems with your code.
But the thing related to this question is that you are fitting the CountVectorizer (vectorizer
) on both train and test data, which is why you are getting different features.
What you should do is:
X1 = vectorizer.fit_transform(train['question'])
# The following line is changedY1 = vectorizer.transform(test['testing'])
Post a Comment for "Number Of Features Of The Model Must Match The Input. Model N_features Is 40 And Input N_features Is 38"