title: How do I classify documents with SciKitLearn using TfIdfVectorizer?
body: <p>The following example shows how one can train a classifier with the Sklearn 20 newsgroups data.</p>
  
  <pre><code>&gt;&gt;&gt; from sklearn.feature_extraction.text import TfidfVectorizer 
  &gt;&gt;&gt; categories = ['alt.atheism', 'talk.religion.misc', 'comp.graphics', 'sci.space']
  &gt;&gt;&gt; newsgroups_train = fetch_20newsgroups(subset='train', ... categories=categories) 
  &gt;&gt;&gt; vectorizer = TfidfVectorizer() &gt;&gt;&gt; vectors = vectorizer.fit_transform(newsgroups_train.data) 
  &gt;&gt;&gt; vectors.shape (2034, 34118)
  </code></pre>
  
  <p>However, I have my own labeled corpus that I would like to use.</p>
  
  <p>After getting a tfidfvector of my own data, would I train a classifier like this?</p>
  
  <pre><code>classif_nb = nltk.NaiveBayesClassifier.train(vectorizer)
  </code></pre>
  
  <p>To recap:
  How can I use my own corpus instead of the 20newsgroups, but in the same way used here?
  How can I then use my TFIDFVectorized corpus to train a classifier?</p>
  
  <p>Thanks!</p>