When you compare two lists, whether of words, customers or species, you need one number for how alike they are. This Jaccard similarity calculator takes the size of set A, the size of set B and the number of items in both to give the Jaccard similarity, the Jaccard distance, the Sørensen–Dice coefficient, the overlap coefficient and the size of the union.
How the calculation works
- Union = |A| + |B| − |A ∩ B|, the number of different items in the two sets together.
- Jaccard similarity = |A ∩ B| ÷ |A ∪ B|. It is 0% for sets with nothing in common and 100% for identical sets. Jaccard distance = 100% − the similarity.
- Sørensen–Dice coefficient = 2 × |A ∩ B| ÷ (|A| + |B|), which gives more weight to the overlap.
- Overlap coefficient = |A ∩ B| ÷ the size of the smaller set. It is 100% when one set is fully contained in the other. The shared count is capped at the smaller set.
Example
Set A has 120 items, set B has 80, and 50 items are in both. The union is 120 + 80 − 50 = 150 items. The Jaccard similarity is 50 ÷ 150 = 33.33%, so the Jaccard distance is 66.67%. The Dice coefficient is 2 × 50 ÷ 200 = 50%, and the overlap coefficient is 50 ÷ 80 = 62.5%, because the smaller set has 80 items.
Why it matters
The measure is a basic tool of data science, search engines, ecology and genetics. It is simple, it does not depend on the order of items, and it can be read directly as a share of the combined items that both sets contain.
Good to know
The calculator works with counts of items, not with the items themselves, so it assumes that the sets have no duplicates. The shared count is limited to the size of the smaller set. For weighted data, where items have different importance, a weighted or generalized Jaccard index is needed. A high similarity says that the sets overlap, not that they are about the same thing.
Related tools
The Venn diagram calculator counts the regions of overlapping sets, and the percentage calculator helps to turn the results into shares.