0
让我先给我的TFIDF措施的理解:TF IDF不相等,当TF在两个文件是相同的
TF(T)=(次项t号码出现在文档中)/(总文档中的术语)的数目
IDF(T)= log_e(的文件总数/文件与在它词条t)
my source, and good explanation
所以有1个IDF度量的每一个字数量在语料库中。
但是Tf对于每个单词和语料库中的每个文档都是“存在”的。
假设一个单词在2个文档中有Tf = 1,那么TfIdf对于这两个单词应该是相同的,对吗?
我想看看这个在R,在这里我的代码:
library(tm)
data("crude")
DTM <- DocumentTermMatrix(crude,control=list(weighting=weightTf))
DTM2 <- DocumentTermMatrix(crude,control=list(weighting=weightTfIdf))
M <- as.matrix(DTM)
M2 <- as.matrix(DTM2)
> M2[7:15,7:9]
Terms
Docs "if "is "may
237 0 0.00000000 0.00000000
242 0 0.00000000 0.00000000
246 0 0.00000000 0.00000000
248 0 0.01153447 0.01500669
273 0 0.00000000 0.00000000
349 0 0.00000000 0.00000000
352 0 0.03650470 0.00000000
353 0 0.00000000 0.00000000
368 0 0.00000000 0.00000000
> M[7:15,7:9]
Terms
Docs "if "is "may
237 0 0 0
242 0 0 0
246 0 0 0
248 0 1 1
273 0 0 0
349 0 0 0
352 0 1 0
353 0 0 0
368 0 0 0
为什么TFIDF不一样呢?我的谬论在哪里?