首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError in scikit-学习CountVectorizer

TypeError in scikit-学习CountVectorizer
EN

Stack Overflow用户
提问于 2013-09-25 14:14:50
回答 1查看 736关注 0票数 2

我正在尝试做一些文本分析与科学学习。但是,当我试图调用CountVectorizer时,会引发错误。示例代码和引发的错误如下:

代码语言:javascript
复制
    >>> from sklearn.feature_extraction.text import CountVectorizer
    >>> corpus = [  'This is the first document.', 'This is the second second document.',  'And    the third one.',  'Is this the first document?', ]
    >>> vectorizer = CountVectorizer(min_df=1)
    >>> X = vectorizer.fit_transform(corpus)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/Library/Python/2.6/site-packages/sklearn/feature_extraction/text.py", line 789, in fit_transform
    vocabulary, X = self._count_vocab(raw_documents, self.fixed_vocabulary)
    File "/Library/Python/2.6/site-packages/sklearn/feature_extraction/text.py", line 716, in _count_vocab
    vocabulary = defaultdict(None)
    TypeError: first argument must be callable

这是我安装的窃听器还是什么东西?其他的例子也很好。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-27 22:11:07

总结一下注释中的讨论:这是Python2.6.1中的一个bug,它已经修复了Python2.6的最新版本(后来作为2.7+,3.2+.)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19007407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档