I want to get keywords of a text by tfidf method with sklenrn
I have got tfidf module, see code below:
from sklearn.feature_extraction import text
tfidf_vect = text.TfidfVectorizer()
texts = get_text_list()
tfidf = tfidf_vect.fit_transform(texts)
now , inputting a new documents as text
res = tfidf_vect.transform(text)
The res is a csr_matrix. The res.indices is positions of words and res.data is tfidf value.
How to sort this res by res.data
reference:http://www.cs.duke.edu/courses/spring14/compsci290/assignments/lab02.html