I used sklearn for calculating TFIDF (Term frequency inverse document frequency) values for documents using command as :
from sklearn.feature_extraction.text import CountVectorizer
count_vect = CountVectorizer()
X_train_counts = count_vect.fit_transform(documents)
from sklearn.feature_extraction.text import TfidfTransformer
tf_transformer = TfidfTransformer(use_idf=False).fit(X_train_counts)
X_train_tf = tf_transformer.transform(X_train_counts)
X_train_tf
is a scipy.sparse
matrix of shape (2257, 35788)
.
How can I get TF-IDF for words in a particular document? More specific, how to get words with maximum TF-IDF values in a given document?