计算两个文档之间的 Jaccard 相似度

数据挖掘 数据挖掘 数据
2022-02-25 17:26:27

数据挖掘:

计算 2-shingles 上 D1 和 D2 的 Jaccard 相似度。辛(D1,D2)=

D1 =敏捷的棕色狐狸跳过懒惰的狗

D2 =杰夫打错了快速的棕色狗跳过了懒惰的狐狸

你能解释一下如何一步一步地得出结论吗?谢谢。

1个回答

您在第二组中忘记了一些2-shingles(二元组但没有重复项),但您的想法是正确的:

S1= { "the quick", "quick brown", "brown fox", "fox jumps", "jumps over", "over the", "the lazy", "lazy dog" }

S2= { "jeff typed", "typed the", "the quick", "quick brown", "brown dog", "dog jumps", "jumps over", "over the", "the lazy", "lazy fox ", "狐狸", "误会" }

备注:对于这个特定的示例,在这两个集合中的每一个中,每个 2 个单词的序列仅出现一次,因此无需删除重复项即可获得该集合。在一般情况下,这可能是必要的(参见 Wikipedia 示例)。

要计算 Jaccard 相似度,我们需要计算:

  • 十字路口S1S2,即共有的 2 个带状疱疹:| { "the quick", "quick brown", "jumps over", "over the", "the lazy" } | = 5
  • 工会S1S2,即所有不同的 2 瓦:| { “the quick”, “quick brown”, “brown fox”, “fox jumps”, “jumps over”, “over the”, “the lazy”, “lazy dog”, “jeff typed”, “typed the” , “棕狗”, “狗跳”, “懒狐”, “狐狸”, “误会” } = 15

杰卡德相似度:

S1S2S1S2=515=0.33