簡體   English   中英

python CountVectorizer()vocabulary_ get方法返回無

[英]python CountVectorizer() vocabulary_ get method returns None

根據http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html上的文檔,我有這段代碼

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'))

輸出如下

dict_keys(['target', 'filenames', 'target_names', 'data', 'DESCR'])
target_names ['false', 'true']
length of data 920
(920, 8773)
None

想知道為什么“無”之后趨向底部(920,8773)

我在“ true”和“ false”文件夾中分別有460個文本文檔

謝謝,

因為'algoritham'一詞從未出現在您的文檔中。

也許您應該嘗試'algorithm'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM