title: How to save TFIDF vectorizer in scikit learn?
body: <p>I am developing a <strong>spam classifier</strong> using scikit learn.</p>
  
  <p>Here is my vectorizing code </p>
  
  <pre class="lang-py prettyprint-override"><code>vectorizer = TfidfVectorizer(
      analyzer='word', 
      sublinear_tf=True,
      strip_accents='unicode',
      token_pattern=r'\w{1,}',
      ngram_range=(1, 1),
      max_features=10000)
  
  
  tfidf = vectorizer.fit(data['text'])
  features = vectorizer.transform(data['text'])
  
  import pickle
  pickle.dump(tfidf, open('tfidf.pickle', 'wb'))
  </code></pre>
  
  <p>Here is what I am doing to predict new input</p>
  
  <pre class="lang-py prettyprint-override"><code>import joblib
  
  model = joblib.load('model')
  
  vect = pickle.load(open('tfidf.pickle', 'rb'))
  
  new = vect.transform(['some new text...'])
  
  mod.predict(new)
  
  </code></pre>
  
  <p>When I open vectorizer file <strong>(tfidf.pickle)</strong> and try to predict a new message it shows me the error as</p>
  
  <blockquote>
    <p><strong>ValueError</strong>: X.shape[1] = 7148 should be equal to 38011, the number of features at training time</p>
  </blockquote>