前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

tf-idf

作者头像
ke1th
发布2019-05-28 23:17:09
6450
发布2019-05-28 23:17:09
举报

版权声明:本文为博主原创文章,转载请注明出处。 https://cloud.tencent.com/developer/article/1437701

TF-IDF 是为了解决 documentterm 的权重问题。

TF (term frequency)

将一个 document 中的每一个 term 都赋予一个权重,最简单的方法就是将 term 在此 document 中出现的次数。用频数表示权重的方法叫做 TF,数学表示为:tft,d\text{tf}_{t,d} ,表示 “document” d 中 “term” t 出现的次数。

IDF(Inverse document Frequency)

使用 TF 方法进行 query 有个很严重的问题:所有的 query term 都被同等的对待。实际情况下,并不是所有的 term 都具有同样的辨别力。比如说,and 这个 term 几乎会出现在所有的 document 中。一个想法是,使用 termdocumentfrequency 来调整 使用 term frequency计算出来的 term 的权重 。idf 就是这么一个调整系数。

dft\text{df}_t : 集合中,包含 “term” tdocument 个数

idft=logN_df_t\text{idf}_t = \log \frac{N}{\text{df}_t} : 其中 N 表示 集合中 document 的个数。 值越大,表示 “term” t 更具有辨别力。

tf-idf weighting

tf-idf weighting 的公式如下:

tf-idft,d=tft,d∗idft

\text{tf-idf}_{t,d} = \text{tf}_{t,d} *\text{idf}_t

在 Query 情况下,如何计算document 的 Score:

Score(q,d)=∑tq_tf-idf_t,d

\text{Score}(q,d) = \sum_{t \in q} \text{tf-idf}_{t,d}

参考资料

https://nlp.stanford.edu/IR-book/html/htmledition/inverse-document-frequency-1.html

https://nlp.stanford.edu/IR-book/html/htmledition/term-frequency-and-weighting-1.html

https://nlp.stanford.edu/IR-book/html/htmledition/tf-idf-weighting-1.html

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年02月20日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • TF (term frequency)
  • IDF(Inverse document Frequency)
  • tf-idf weighting
  • 参考资料
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档