【问题标题】:TfidfVectorizer does not use the whole set of words in all documents?TfidfVectorizer 不使用所有文档中的整组单词?
【发布时间】:2015-07-14 20:30:47
【问题描述】:

我正在尝试使用 TfidfVectorizer 构建 TFIDF 模型。即使我将 min_df 设置为 1,特征名称列表(即稀疏矩阵的列数)也比文档的单词集长度短。发生了什么?

【问题讨论】:

标签: python nlp tf-idf


【解决方案1】:

你检查过 stop_words 和 max_features 吗?如果您在这两个中的任何一个中提供值,它将排除一些单词。

【讨论】:

  • 是的!我发现问题是 stop_words。从 TfidfVectorizer 的输入中删除 stop_words 和在 TfidfVectorizer 中打开 stop_words 选项是有区别的。不知道为什么,但现在输出与我的预期一致。谢谢。
猜你喜欢
  • 2019-07-29
  • 2017-08-25
  • 2018-11-24
  • 1970-01-01
  • 2022-01-12
  • 1970-01-01
  • 2021-05-11
  • 1970-01-01
  • 2017-06-14
相关资源
最近更新 更多