首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python CountVectorizer() vocabulary_ get方法返回None

python CountVectorizer() vocabulary_ get方法返回None
EN

Stack Overflow用户
提问于 2016-02-09 07:34:05
回答 1查看 2K关注 0票数 1

根据http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html上的文档,我有这段代码

代码语言:javascript
复制
from sklearn.datasets import load_files
from sklearn.feature_extraction.text import CountVectorizer

count_vect = CountVectorizer()

my_bunch = load_files("c:\\temp\\billing_test\\")

my_data = my_bunch['data']
print (my_bunch.keys())
print('target_names',my_bunch['target_names'])
print('length of data' , len(my_bunch['data']))


X_train_counts = count_vect.fit_transform(my_data)
print(X_train_counts.shape)

print ( count_vect.vocabulary_.get(u'algorithm'))

输出如下所示

代码语言:javascript
复制
dict_keys(['target', 'filenames', 'target_names', 'data', 'DESCR'])
target_names ['false', 'true']
length of data 920
(920, 8773)
None

想知道为什么“无”之后的底部(920,8773)

我在"true“和"false”文件夹中都有大约460个文本文档。

谢谢,

EN

回答 1

Stack Overflow用户

发布于 2016-02-09 07:48:50

因为word 'algoritham'从未出现在您的文档中。

也许你应该试试'algorithm'

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

https://stackoverflow.com/questions/35281349

复制
相关文章

相似问题

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