ValueError: X has 1460 features, but MultinomialNB is expecting 3925 features as input
kindly help
Hey Amira,
Thank you for reaching out!
Could you please share a screenshot of your code together with the error?
Kind regards,
365 Hristina
img1
img2
img3
Hey Hristina,
It worked for me before. But now it is also showing the same error. I looked for workaround, I didn't find any. I've attached 3 images of the code. I hope you can identify the reason. In my opinion, there is something to do with the version. Mine is latest version.
Thank you.
Hey Tulasi,
Thank you for reaching out.
Note that the following line of code
x_test_transf = vectorizer.fit_transform(x_test)
should instead read
x_test_transf = vectorizer.transform(x_test)
This should solve the problem, however, let me know if you encounter other issues.
Kind regards,
365 Hristina
It solved the problem. I missed the point that we have to fit it only on training data. I really like the way you identify the mistakes. Thank you.!