【发布时间】:2017-08-01 13:02:44
【问题描述】:
我正在尝试将 CountVectorizer 模块与 Sci-kit Learn 一起使用。根据我的阅读,它似乎可以用于句子列表,例如:
['这是第一个文档。','这是第二个第二个文档。','还有第三个。','这是第一个文档吗?']
但是,有没有办法对列表形式的单词集合进行向量化,例如 [['this', 'is', 'text', 'document', 'to', 'analyze'], [' and', 'this', 'is', 'the', 'second'],['and', 'this', 'and', 'that', 'are', 'third']?
我正在尝试使用' '.join(wordList) 将每个列表转换为一个句子,但出现错误:
TypeError:序列项 13329:预期的字符串或 Unicode,生成器 找到了
当我尝试运行时:
vectorizer = CountVectorizer(min_df=50)
ratings = vectorizer.fit_transform([' '.join(wordList)])
谢谢!
【问题讨论】:
标签: python machine-learning scikit-learn nlp