title: Naive Bayes ValueError: Dimension Mismatch
body: <p>I am attempting to make predictions of categories of text data, one of which is Naive Bayes. The training data contains 7 categories, 802 data points. After balancing with SMOTE all 7 categories now have 134 data points for a total of 938.</p>
  <p>Training Data:</p>
  <pre><code>df_train['Categories'].value_counts()
  
  Category 1         134
  Category 2         130
  Category 3         128
  Category 4         106
  Category 5         103
  Category 6         101
  Category 7         100
  
  
  X = df_train['Element']
  y = df_train['Categories']
  
  count_vect = CountVectorizer(ngram_range=(1,2))
  X_vect = count_vect.fit_transform(X)
  print(X_vect.shape)
  X_res, y_res = sm.fit_resample(X_vect, y)
  print(X_res.shape)
  
  (802, 747)
  (938, 747)
  </code></pre>
  <p>My test data to be predicted upon contains 46 text elements that vectorizes into 280 features.</p>
  <pre><code>df_test_bagofwords = count_vect.transform(df_test['Elements'])
  print(df_test_bagofwords.shape)
  
  (46, 280)
  
  mnb = MultinomialNB().fit(X_res, y_res)
  mnb_pred = mnb.predict(df_test_bagofwords)
  
  ValueError: dimension mismatch
  </code></pre>
  <p>When attempting the same with SVM I get further information:</p>
  <pre><code>ValueError: X.shape[1] = 280 should be equal to 747, the number of features at training time
  </code></pre>
  <p>I thought count_vect.transform() would fit the test data to the vectorized and fitted training data. But this error is consistent.</p>