tf-idf 使用来自 Google 的一元词频率数据

Chr*_*son 5 nlp tf-idf

我正在尝试找出一组政府文件中的重要术语。生成术语频率没有问题。

对于文档频率,我希望使用Peter Norvig 在“美丽数据”一章中发布的方便的 Python 脚本和随附数据,其中包括来自 Web 的庞大数据语料库中一元语法的频率。

然而,我对 tf-idf 的理解是,“文档频率”是指包含某个术语的文档数量,而不是该术语的总单词数这是我们从 Norvig 脚本中得到的。我仍然可以使用这些数据进行粗略的 tf-idf 操作吗?

这是一些示例数据:

word    tf       global frequency
china   1684     0.000121447
the     352385   0.022573582
economy 6602     0.0000451130774123
and     160794   0.012681757
iran    2779     0.0000231482902018
romney  1159     0.000000678497795593 
Run Code Online (Sandbox Code Playgroud)

简单地用 tf 除以 gf 会得到“the”比“economy”更高的分数,这是不对的。也许我缺少一些基本的数学知识?

Ati*_*gur 4

据我了解,全局频率等于罗伯逊此处提到的“逆总术语频率” 。来自罗伯逊的论文:

One possible way to get away from this problem would be to make a fairly radical re-
placement for IDF (that is, radical in principle, although it may be not so radical 
in terms of its practical effects). ....
the probability from the event space of documents to the event space of term positions 
in the concatenated text of all the documents in the collection. 
Then we have a new measure, called here 
inverse total term frequency:
...
On the whole, experiments with inverse total term frequency weights have tended to show
that they are not as effective as IDF weights
Run Code Online (Sandbox Code Playgroud)

根据本文,您可以使用逆全局频率作为 IDF 术语,尽管比标准术语更粗糙。

此外,您还缺少停用词删除。几乎所有文档中都使用了诸如 the 之类的词,因此它们不提供任何信息。在 tf-idf 之前,您应该删除此类停用词。