Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

jaccard index two vectors R

jaccard <- function(M, user1, user2) {
  sums = rowSums(M[,c(user1, user2)])

  similarity = length(sums[sums==2])
  total = length(sums[sums==1]) + similarity
  
  similarity/total
}
Source by jootse84.github.io #
 
PREVIOUS NEXT
Tagged: #jaccard #index #vectors #R
ADD COMMENT
Topic
Name
3+2 =