`
gaojingsong
  • 浏览: 1182445 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

【TF-IDF介绍】

阅读更多

TF-IDF(term frequency–inverse document frequency)是一种用于资讯检索与资讯探勘的常用加权技术, TFIDF的主要思想是:如果某个词或短语在一篇文章中出现的频率TF高,并且在其他文章中很少出现,则认为此词或者短语具有很好的类别区分能力,适合用来分类。TFIDF实际上是:TF * IDF,TF词频(Term Frequency),IDF反文档频率(Inverse Document Frequency)。TF表示词条在文档d中出现的频率。

In information retrieval, tf–idf, short for term frequency–inverse document frequency, is a numerical statistic that is intended to reflect how important a word is to a document in a collection or corpus.[1] It is often used as a weighting factor in information retrieval, text mining, and user modeling. The tf-idf value increases proportionally to the number of times a word appears in the document, but is offset by the frequency of the word in the corpus, which helps to adjust for the fact that some words appear more frequently in general. Nowadays, tf-idf is one of the most popular term-weighting schemes. For instance, 83% of text-based recommender systems in the domain of digital libraries use tf-idf[2].

Variations of the tf–idf weighting scheme are often used by search engines as a central tool in scoring and ranking a document's relevance given a user query. tf–idf can be successfully used for stop-words filtering in various subject fields including text summarization and classification.

One of the simplest ranking functions is computed by summing the tf–idf for each query term; many more sophisticated ranking functions are variants of this simple model.

 

 

 

Term frequency

Suppose we have a set of English text documents and wish to determine which document is most relevant to the query "the brown cow". A simple way to start out is by eliminating documents that do not contain all three words "the", "brown", and "cow", but this still leaves many documents. To further distinguish them, we might count the number of times each term occurs in each document and sum them all together; the number of times a term occurs in a document is called its term frequency.

The first form of term weighting is due to Hans Peter Luhn (1957) and is based on the Luhn Assumption:

The weight of a term that occurs in a document is simply proportional to the term frequency. 

 

Inverse document frequency

Because the term "the" is so common, term frequency will tend to incorrectly emphasize documents which happen to use the word "the" more frequently, without giving enough weight to the more meaningful terms "brown" and "cow". The term "the" is not a good keyword to distinguish relevant and non-relevant documents and terms, unlike the less common words "brown" and "cow". Hence an inverse document frequency factor is incorporated which diminishes the weight of terms that occur very frequently in the document set and increases the weight of terms that occur rarely.

Karen Spärck Jones (1972) conceived a statistical interpretation of term specificity called Inverse Document Frequency (IDF), which became a cornerstone of term weighting:

The specificity of a term can be quantified as an inverse function of the number of documents in which it occurs. 

 

IDF的主要思想是:如果包含词条t的文档越少,也就是n越小,IDF越大,则说明词条t具有很好的类别区分能力。如果某一类文档C中包含词条t的文档数为m,而其它类包含t的文档总数为k,显然所有包含t的文档数n=m + k,当m大的时候,n也大,按照IDF公式得到的IDF的值会小,就说明该词条t类别区分能力不强。但是实际上,如果一个词条在一个类的文档中频繁出现,则说明该词条能够很好代表这个类的文本的特征,这样的词条应该给它们赋予较高的权重,并选来作为该类文本的特征词以区别与其它类文档。这就是IDF的不足之处.

 

案例:假如一篇文件的总词语数是100个,而词语“母牛”出现了3次,那么“母牛”一词在该文件中的词频就是3/100=0.03。一个计算文件频率 (DF) 的方法是测定有多少份文件出现过“母牛”一词,然后除以文件集里包含的文件总数。所以,如果“母牛”一词在1,000份文件出现过,而文件总数是10,000,000份的话,其逆向文件频率就是 lg(10,000,000 / 1,000)=4。最后的TF-IDF的分数为0.03 * 4=0.12。

 

IDF的主要思想是:如果包含词条t的文档越少,也就是n越小,IDF越大,则说明词条t具有很好的类别区分能力。如果某一类文档C中包含词条t的文档数为m,而其它类包含t的文档总数为k,显然所有包含t的文档数n=m+k,当m大的时候,n也大,按照IDF公式得到的IDF的值会小,就说明该词条t类别区分能力不强。但是实际上,如果一个词条在一个类的文档中频繁出现,则说明该词条能够很好代表这个类的文本的特征,这样的词条应该给它们赋予较高的权重,并选来作为该类文本的特征词以区别与其它类文档。这就是IDF的不足之处. 在一份给定的文件里,词频(term frequency,TF)指的是某一个给定的词语在该文件中出现的频率。这个数字是对词数(term count)的归一化,以防止它偏向长的文件。(同一个词语在长文件里可能会比短文件有更高的词数,而不管该词语重要与否。)对于在某一特定文件里的词语  t_{i}  来说,它的重要性可表示为:

 \mathrm{tf_{i,j}} = \frac{n_{i,j}}{\sum_k n_{k,j}}

以上式子中 n_{i,j} 是该词在文件d_{j}中的出现次数,而分母则是在文件d_{j}中所有字词的出现次数之和。

逆向文件频率(inverse document frequency,IDF)是一个词语普遍重要性的度量。某一特定词语的IDF,可以由总文件数目除以包含该词语之文件的数目,再将得到的商取对数得到:

 \mathrm{idf_{i}} =  \log \frac{|D|}{|\{j: t_{i} \in d_{j}\}|}

其中

  • |D|:语料库中的文件总数
  •  |\{ j: t_{i} \in d_{j}\}| :包含词语 t_{i} 的文件数目(即 n_{i,j} \neq 0的文件数目)如果该词语不在语料库中,就会导致被除数为零,因此一般情况下使用1 + |\{j : t_{i} \in d_{j}\}|

然后

 \mathrm{tf{}idf_{i,j}} = \mathrm{tf_{i,j}} \times  \mathrm{idf_{i}}

某一特定文件内的高词语频率,以及该词语在整个文件集合中的低文件频率,可以产生出高权重的TF-IDF。因此,TF-IDF倾向于过滤掉常见的词语,保留重要的词语。

 

原创不易,欢迎打赏,请认准正确地址,谨防假冒



 

 



 

0
0
分享到:
评论

相关推荐

    tf-idf_tf-idf_

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和文本挖掘领域广泛使用的权重计算方法,用于评估一个词在文档中的重要性。这个概念基于两个主要因素:词频(Term Frequency, TF)和逆文档...

    TF-IDF与余弦相似性的应用

    TF-IDF与余弦相似性的应用 TF-IDF(Term Frequency-Inverse Document Frequency)是一种常用的关键词提取算法,应用于自动关键词提取、信息检索等领域。该算法的优点是简单快速,结果比较符合实际情况。TF-IDF 算法...

    Using_TF-IDF_to_Determine_Word_Relevance_in_Document_Queries

    ### 使用TF-IDF确定文档查询中的词相关性 在当今数据驱动的世界中,从大量文本信息中高效地检索相关信息是一项至关重要的技能。本文探讨了如何应用TF-IDF(Term Frequency-Inverse Document Frequency)来确定文档...

    NLP:基于TF-IDF的中文关键词提取.zip

    在这个主题中,"NLP:基于TF-IDF的中文关键词提取"是一个项目,它利用TF-IDF算法来从中文文本中提取具有代表性的关键词。TF-IDF是一种经典的文本特征权重计算方法,广泛应用于信息检索、文档分类和关键词提取等领域...

    基于TF-IDF算法抽取

    ### 基于TF-IDF算法抽取文章关键词 #### 一、引言 TF-IDF(Term Frequency-Inverse Document Frequency)是一种广泛应用于信息检索与文本挖掘领域的统计方法,用于评估单词对于一个文档集或者语料库中单个文档的...

    基于特定语料库的TF-IDF的中文关键词提取

    在"tf-idf-keyword-master"这个压缩包文件中,很可能包含了实现TF-IDF关键词提取的代码框架或者示例。用户可能需要进一步了解代码结构,学习如何加载特定语料库,如何进行预处理,如何计算TF-IDF值,以及如何输出和...

    C语言、Python实现TF-IDF算法

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和自然语言处理中广泛使用的统计方法,用于评估一个词在文档中的重要性。这个方法基于两个核心概念:词频(Term Frequency, TF)和逆文档频率...

    LDA和TF-IDF算法的相关论文

    《LDA与TF-IDF算法:深度探讨与应用》 在信息检索和自然语言处理领域,LDA(Latent Dirichlet Allocation)和TF-IDF(Term Frequency-Inverse Document Frequency)是两种至关重要的算法,它们在文本分析、文档分类...

    TF-IDF.zip_TF-IDF java_java tf idf_tf idf_tf-idf

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和自然语言处理中广泛使用的统计方法,用于评估一个词在文档集合中的重要性。在Java编程环境下,TF-IDF可以帮助我们提取文本的关键信息,理解...

    TF-IDF.py.zip_TF-IDF WEIGHT_tf-idf_tf_idf_特征提取

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和自然语言处理中广泛使用的文本特征表示方法。它能够衡量一个词在文档中的重要性,适用于文档集合的特征提取,帮助我们理解文档的主题和区分...

    基于TF-IDF文本向量化的SQL注入攻击检测.pdf

    基于 TF-IDF 文本向量化的 SQL 注入攻击检测 SQL 注入攻击是最常见的 Web 应用程序攻击手段,利用机器学习检测 SQL 注入攻击已成为一种趋势。该论文提出了基于 TF-IDF 文本向量化的 SQL 注入攻击检测方法,旨在提高...

    基于Python实现TF-IDF矩阵表示(人工智能实验)【100011921】

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和文本挖掘领域广泛使用的权重计算方法,用于评估一个词在文档中的重要性。这个概念基于两个原则:词频(Term Frequency, TF)和逆文档频率...

    tf-idf.zip_Information Retrival_python IR_python TF-IDF_tf-idf

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种在信息检索和文本挖掘领域广泛使用的统计方法,用于评估一个词在文档中的重要性。它基于两个概念:词频(Term Frequency, TF)和逆文档频率(Inverse ...

    TF-IDF.zip_tf-idf_tfidf

    TF-IDF,全称为Term Frequency-Inverse Document Frequency,是一种在信息检索和文本挖掘领域广泛应用的统计方法,用于评估一个词在文档集或语料库中的重要性。它结合了词频(Term Frequency, TF)和逆文档频率...

    基于改进TF-IDF算法的牛疾病智能诊断系统.pdf

    本文介绍了一种基于改进TF-IDF算法的牛疾病智能诊断系统。传统的TF-IDF算法存在一些缺陷,例如无法合理地代表某疾病的症状,降低智能诊断系统的性能。为了解决这个问题,本文提出了一个改进的TF-IDF算法,并将其应用...

    关键词提取TF-IDF算法综述

    在介绍TF-IDF算法之前,需要先了解一下文本分类和空间向量模型(VSM)。文本分类是将文本数据按照其内容和特性分配到一个或多个类别中的过程。空间向量模型是文本表示的一种方法,它通过将文档表示为向量空间中的点...

    TF-IDF.rar_TF-IDF algorithm

    TF-IDF算法是一种在信息检索和自然语言处理领域广泛应用的文本表示方法,它能够量化一个词在文档中的重要性。TF-IDF代表“词频-逆文档频率”(Term Frequency-Inverse Document Frequency),该方法结合了词频(Term ...

    使用python进行朴素贝叶斯的数据分析,使用TF-IDF方法整理数据

    在数据分析领域,Python是一种非常强大的工具,而朴素贝叶斯(Naive Bayes)和TF-IDF(Term Frequency-Inverse Document Frequency)则是两种常见的技术,常用于文本分类和信息检索。接下来,我们将深入探讨这两个...

    TF-IDF介绍1

    TF-IDF(Term Frequency-Inverse Document Frequency)是一种用于信息检索和文本挖掘的统计技术,它通过结合词频(TF)和逆文档频率(IDF)来评估一个词在文档中的重要性。TF-IDF的核心思想是,那些在单个文档中频繁...

Global site tag (gtag.js) - Google Analytics