I'm transforming a text in tf-idf from sklearn. I made the model:
from sklearn.feature_extraction.text import TfidfVectorizer corpus = words vectorizer = TfidfVectorizer(min_df = 15) tf_idf_model = vectorizer.fit_transform(corpus)
And now I'm making vectors for different sets of words (documents), like:
word_set = ['dog', 'cat', 'foo'] v = vectorizer.transform(word_set)
But I want just one vector of these words, to compare to other documents. But when I use transform, the shape of v becomes:
<3x56492 sparse matrix of type '<class 'numpy.float64'>' with 3 stored elements in Compressed Sparse Row format>
I want a vector with shape 1x56492, and not 3x56492.. I'm certainly missing something here. Maybe you guys have some tips?
Thank you very much in advance.