The following example shows how one can train a classifier with the Sklearn 20 newsgroups data.
>>> from sklearn.feature_extraction.text import TfidfVec
To address questions from comments; The whole basic process of working with tfidf representation in some classification task you should:
In general, for sklearn the flow is:
You did not mention your data format but if it is csv file with some rows,flow could be:
And once you have trained classifier you can call predict for new data. Remeber to convert new data to same format as data on which you trained by using above used and fitted vectorizer before passing it to classif.predict.