I have code that runs basic TF-IDF vectorizer on a collection of documents, returning a sparse matrix of D X F where D is the number of documents and F is the number of terms. No problem.
But how do I find the TF-IDF score of a specific term in the document? i.e. is there some sort of dictionary between terms (in their textual representation) and their position in the resulting sparse matrix?
Yes. See
.vocabulary_
on your fitted/transformed TF-IDF vectorizer.It is a dictionary of the form:
{word : column index in array}