📅  最后修改于: 2022-03-11 14:52:34.086000             🧑  作者: Mango
jaccard <- function(M, user1, user2) {
sums = rowSums(M[,c(user1, user2)])
similarity = length(sums[sums==2])
total = length(sums[sums==1]) + similarity
similarity/total
}