如何使用tfidf python转换数据

时间:2018-08-09 14:27:11

标签: python-2.7 scikit-learn

from sklearn.feature_extraction.text import TfidfVectorizer
transformer = TfidfVectorizer(stop_words="english")
word_data_trans = transformer.fit_transform(word_data)

我遇到这样的错误:

79 from sklearn.feature_extraction.text import TfidfVectorizer
     80 transformer = TfidfVectorizer(stop_words="english")
---> 81 word_data_trans = transformer.fit_transform(word_data)
     82 word_list = transformer.get_feature_names()
     83 print "Length of word_list: ", len(word_list)

C:\ProgramData\Anaconda3\envs\ipykernel_py2\lib\site-packages\sklearn\feature_extraction\text.pyc in fit_transform(self, raw_documents, y)
   1379             Tf-idf-weighted document-term matrix.
   1380         """
-> 1381         X = super(TfidfVectorizer, self).fit_transform(raw_documents)
   1382         self._tfidf.fit(X)
   1383         # X is already a transformed view of raw_documents so

我不知道我现在在做什么

0 个答案:

没有答案