小编Arc*_*ana的帖子

CountVectorizer不打印词汇表

我已经安装了python 2.7,numpy 1.9.0,scipy 0.15.1和scikit-learn 0.15.2.现在,当我在python中执行以下操作时:

train_set = ("The sky is blue.", "The sun is bright.")
test_set = ("The sun in the sky is bright.",
"We can see the shining sun, the bright sun.")

from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()

print vectorizer


    CountVectorizer(analyzer=u'word', binary=False, charset=None,
    charset_error=None, decode_error=u'strict',
    dtype=<type 'numpy.int64'>, encoding=u'utf-8', input=u'content',
    lowercase=True, max_df=1.0, max_features=None, min_df=1,
    ngram_range=(1, 1), preprocessor=None, stop_words=None,
    strip_accents=None, token_pattern=u'(?u)\\b\\w\\w+\\b',
    tokenizer=None, vocabulary=None)

     vectorizer.fit_transform(train_set)
    print vectorizer.vocabulary

    None.
Run Code Online (Sandbox Code Playgroud)

实际上应该打印以下内容:

CountVectorizer(analyzer__min_n=1,
analyzer__stop_words=set(['all', 'six', 'less', 'being', 'indeed', 'over',    
 'move', 'anyway', 'four', 'not', 'own', …
Run Code Online (Sandbox Code Playgroud)

python numpy scipy

10
推荐指数
2
解决办法
1万
查看次数

标签 统计

numpy ×1

python ×1

scipy ×1