UNPKG

jaccard-array

Version:

Very simple package for measuring the similarity of two sets by their shared members.

26 lines (16 loc) 630 B
# Jaccard Very simple package for measuring the similarity of two sets by their shared members. The module exports a single function that accepts two arrays of attributes and returns their [Jaccard Index](https://en.wikipedia.org/wiki/Jaccard_index). ## Installation ``` $ npm install jaccard-array ``` ## Usage ```javascript const jaccard = require('jaccard-array'); var setA, setB, similarity; // find the similarity of two movies based on the people that liked them setA = ['Sara', 'Tom', 'Steve', 'Peter', 'Allison', 'Anne']; setB = ['Fred', 'Dan', 'Steve', 'Peter', 'Allison']; similarity = jaccard(setA, setB); ```