How to get the tfidf vector for a given document
<p>I have the following file:</p>

<pre><code>id  review
1   "Human machine interface for lab abc computer applications."
2   "A survey of user opinion of computer system response time."
3   "The EPS user interface management system."
4   "System and human system engineering testing of EPS."              
5   "Relation of user perceived response time to error measurement."
6   "The generation of random binary unordered trees."
7   "The intersection graph of paths in trees."
8   "Graph minors IV Widths of trees and well quasi ordering."
9   "Graph minors A survey."
10  "survey is a state of art."
</code></pre>

<p>Each row concern a document.</p>

<p>I convert these documents to a corpus and i find for each word its TFIDF:</p>

<pre><code>from collections import defaultdict
import csv
from sklearn.feature_extraction.text import TfidfVectorizer

reviews = defaultdict(list)
with open("C:/Users/user/workspacePython/Tutorial/data/unlabeledTrainData.tsv", "r") as sentences_file:
    reader = csv.reader(sentences_file, delimiter='\t')
    reader.next()
    for row in reader:
        reviews[row[1]].append(row[1])

for id, review in reviews.iteritems():
    reviews[id] = " ".join(review)


corpus = []
for id, review in sorted(reviews.iteritems(), key=lambda t: id):
    corpus.append(review)

tf = TfidfVectorizer(analyzer='word', ngram_range=(1,1), min_df = 1, stop_words = 'english')
tfidf_matrix = tf.fit_transform(corpus)
</code></pre>

<p>My question is: How can i get for a given document(from the above file) its correponding vector(row) in the tfidf_matrix.</p>

<p>Thank you</p>