📜  jaccard 索引两个向量 R - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:34.086000             🧑  作者: Mango

代码示例1
jaccard <- function(M, user1, user2) {
  sums = rowSums(M[,c(user1, user2)])

  similarity = length(sums[sums==2])
  total = length(sums[sums==1]) + similarity
  
  similarity/total
}