NLTK是否实施了TF-IDF?

2024-04-27 20:16:40 发布

您现在位置:Python中文网/ 问答频道 /正文

scikit-learngensim中有TF-IDF实现。

有一些简单的实现Simple implementation of N-Gram, tf-idf and Cosine similarity in Python

为了避免重新发明轮子

  • NLTK中真的没有TF-IDF吗?
  • 是否有可以在NLTK中操作以实现TF-IDF的子包?如果有的话怎么办?

在这篇博文中,它说NLTK没有它。是真的吗?http://www.bogotobogo.com/python/NLTK/tf_idf_with_scikit-learn_NLTK.php


Tags: andoftfscikitsimplelearnimplementationgram
2条回答

NLTK TextCollection类有一个计算术语tf idf的方法。文档是here,源是here。但是,它说“加载可能很慢”,所以使用scikit learn可能更好。

我想,有足够的证据可以断定在NLTK中不存在TF-IDF:

  1. Unfortunately, calculating tf-idf is not available in NLTK so we'll use another data analysis library, scikit-learn

    COMPSCI 290-01 Spring 2014 lab

  2. 更重要的是,源代码不包含任何与tfidf(或tf-idf)相关的内容。例外情况是NLTK contrib,它包含TF-IDF的map-reduce implementation

related question中提到了tf idf的几个lib。

Upd:search bytf idftf_idf让我们找到@yvespeirsman已经找到的函数

相关问题 更多 >