dimension mismatch error in CountVectorizer MultinomialNB

前端 未结 1 1694
离开以前
离开以前 2021-01-19 19:48

Before I lodge this question, I have to say I\'ve thoroughly read more than 15 similar topics on this board, each with somehow different recommendations, but all of them jus

相关标签:
1条回答
  • 2021-01-19 19:59

    Your CountVectorizer has already been fitted with the training data. So for your test data, you just want to call transform(), not fit_transform().

    Otherwise, if you use fit_transform() again on your test data, you get different columns based on the unique vocabulary of the test data. So just fit once for training.

    X_testcv = cv.transform(X_test)
    
    0 讨论(0)
提交回复
热议问题