Created
January 21, 2015 06:52
-
-
Save andrewluetgers/55174d0886c79c3d0696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jaccardIndex(s1, s2) { | |
// Jaccard index: http://en.wikipedia.org/wiki/Jaccard_index | |
// size of the intersection divided by the size of the union of the sample sets | |
s1 = _.isArray(s1) ? s1 : _.keys(s1); | |
s2 = _.isArray(s2) ? s2 : _.keys(s2); | |
return _.intersection(s1, s2).length / _.union(s1, s2).length | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment