title: ValueError: X.shape[1] = 8 should be equal to 1500, the number of features at training time
body: <p>I'm using sklearn to train a machine learning model for sentiment analysis on persian text. Here is my code: </p>
  
  <pre><code>vectorizer = TfidfVectorizer(max_features=1500,
                               sublinear_tf=True,
                               use_idf=True,
                               stop_words=stop_words)
  
  X = vectorizer.fit_transform(data).toarray()
  
  le = LabelEncoder()
  le.fit(["pos", "neu", "neg"])
  y = le.transform(data_labels)
  
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
  
  classifier_rbf = SVC(kernel='rbf', gamma=1, C=1)
  classifier_rbf.fit(X_train, y_train)
  y_pred = classifier_rbf.predict(X_test)
  
  with open('svm_rbf_classifier.pkl', 'wb') as fid:
      _pickle.dump(y_pred, fid)
  
  with open('tfidf_vectorizer.pkl', 'rb') as fid:
      vectorizer = _pickle.load(fid)
  
  print(classification_report(y_test, y_pred))
  print()
  print(accuracy_score(y_test, y_pred))
  </code></pre>
  
  <p>After train and test phases, I just want to load my vectorizer and classifier to predict Persian comments one by one. I wrote this piece of code for achieving this: </p>
  
  <pre><code>with open('tfidf_vectorizer.pkl', 'rb') as fid:
      vectorizer = _pickle.load(fid)
  
  with open('svm_rbf_classifier.pkl', 'rb') as fid:
      classifier_rbf = _pickle.load(fid)
  
  comment = 'من نسبت به نتایجی که تیم این روزا کسب میکنه نگرانم'
  X = vectorizer.fit_transform([comment]).toarray()
  
  predicted = classifier_rbf.predict(X)
  print(predicted)
  </code></pre>
  
  <p>but when I try it I get the following error: </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Projects/Sentiment/test.py", line 18, in &lt;module&gt;
      predicted = classifier_rbf.predict(X)
    File "C:\Python\Python36\lib\site-packages\sklearn\svm\base.py", line 576, in predict
      y = super(BaseSVC, self).predict(X)
    File "C:\Python\Python36\lib\site-packages\sklearn\svm\base.py", line 325, in predict
      X = self._validate_for_predict(X)
    File "C:\Python\Python36\lib\site-packages\sklearn\svm\base.py", line 478, in _validate_for_predict
      (n_features, self.shape_fit_[1]))
  ValueError: X.shape[1] = 8 should be equal to 1500, the number of features at training time
  </code></pre>
  
  <p>I don't understand this since I'm using the same vectorizer that I used for train and test. What am I doing wrong? </p>