【发布时间】:2016-04-23 07:58:11
【问题描述】:
编辑:这是我最终想问的问题:Understanding min_df and max_df in scikit CountVectorizer
我正在阅读 scikit-learn CountVectorizer 的文档,并注意到在讨论 max_df 时,我们关心令牌的文档频率:
max_df : float in range [0.0, 1.0] or int, default=1.0
When building the vocabulary ignore terms that have a document frequency strictly higher than the given threshold (corpus-specific stop words). If float, the parameter represents a proportion of documents, integer absolute counts. This parameter is ignored if vocabulary is not None.
但是当我们考虑max_features时,我们对词频感兴趣:
max_features : int or None, default=None
If not None, build a vocabulary that only consider the top max_features ordered by term frequency across the corpus.
我很困惑:如果我们使用max_df,并说我们将其设置为 10,我们不是说“忽略任何出现超过 10 次的令牌”吗?
如果我们将max_features 设置为100,我们不是说“只使用在整个语料库中出现次数最多的100 个标记”吗?
如果我猜对了……那么使用“词频”和“文档频率”时的措辞有什么区别?
【问题讨论】:
-
它们几乎就像它在锡上所说的那样 - 文档频率是 documents 的频率(包含该术语的文档占所有文档的一部分),术语频率是频率条款。
-
我不明白你所说的“措辞不同”。
-
@pvg 所以如果一个词的“文档频率”为 0.5,这意味着它出现在语料库中的一半文本中?如果我们使用 max_df = 0.5,这肯定会与 idf 中的值混淆
-
@MonicaHeddneck:如果你不加选择地使用
max_df,那么是的,这就是为什么max_df被应用于“语料库特定的停用词”。
标签: python scikit-learn tf-idf