Created
May 29, 2017 18:17
-
-
Save jmarmolejos/ad57881fdd273ce0aa45b82524162294 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 findJaccardIndex(collection1, collection2) { | |
return _.intersection(collection1, collection2).length / _.union(collection1, collection2).length | |
} | |
console.log(findJaccardIndex("Foo".split(''), 'Bar'.split(''))); // 0 | |
console.log(findJaccardIndex("Foo".split(''), 'Far'.split(''))); // 0.2 | |
console.log(findJaccardIndex("Foo".split(''), 'For'.split(''))); // 0.66 | |
console.log(findJaccardIndex("Foo".split(''), 'Foo'.split(''))); // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment