Skip to content

Instantly share code, notes, and snippets.

@geotheory
Last active March 23, 2019 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geotheory/51412cf22240c68afb70046643914075 to your computer and use it in GitHub Desktop.
Save geotheory/51412cf22240c68afb70046643914075 to your computer and use it in GitHub Desktop.
jaccard_similarity = function(x, y){
x = unique(x)
y = unique(y)
if(length(x) + length(y) == 0) return(1)
xy = length(intersect(x, y))
xy / (length(x) + length(y) - xy)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment