min_df 和 max_df 的默认值分别为 1 和 1.0。这些默认值实际上根本没有做任何事情。
话虽如此,我相信@Ffisegydd 回答目前接受的回答并不完全正确。
例如,使用默认值运行这个,看看当min_df=1和max_df=1.0时,然后
1) 使用至少出现在一个文档中的所有标记(例如,所有标记!)
2) 使用出现在所有文档中的所有标记(我们将使用一个候选人进行测试:无处不在)。
cv = CountVectorizer(min_df=1, max_df=1.0, lowercase=True)
# here is just a simple list of 3 documents.
corpus = ['one two three everywhere', 'four five six everywhere', 'seven eight nine everywhere']
# below we call fit_transform on the corpus and get the feature names.
X = cv.fit_transform(corpus)
vocab = cv.get_feature_names()
print vocab
print X.toarray()
print cv.stop_words_
我们得到:
[u'eight', u'everywhere', u'five', u'four', u'nine', u'one', u'seven', u'six', u'three', u'two']
[[0 1 0 0 0 1 0 0 1 1]
[0 1 1 1 0 0 0 1 0 0]
[1 1 0 0 1 0 1 0 0 0]]
set([])
保留所有令牌。没有停用词。
进一步弄乱参数将阐明其他配置。
为了乐趣和洞察力,我还建议使用stop_words = 'english' 并看到,特别是,除了“七”之外的所有单词都被删除了!包括“无处不在”。