Calculate the Jaccard index (similarity coefficient) of two sets from their items or overlap counts, with Jaccard distance and the Dice coefficient.

Separate items with commas, semicolons or new lines. Duplicates are ignored.

Optional settings

Calculator Functions

FunctionWhat it doesWhat it requires
Jaccard index from item setsFinds the Jaccard index of two lists of items and shows which items are shared and which belong to one set onlyRequires the items of set A and set B, separated by commas, semicolons or new lines
Jaccard index from overlap countsFinds the Jaccard index from counts when the items themselves are not listedRequires the shared item count, the A-only item count and the B-only item count
Shared items needed for a targetFinds the smallest whole number of shared items that reaches a target similarityRequires the size of set A, the size of set B and the target similarity in percent

Every function also reports the similarity as a percentage, the Jaccard distance, the Sørensen–Dice coefficient and the two set sizes. Item matching ignores letter case unless case-sensitive matching is chosen, and duplicate items in a list count once. Two empty sets have no Jaccard index.

Jaccard Coefficient Formulas

J = I ÷ (A + B − I) [1]
JJaccard coefficient, from 0 (nothing shared) to 1 (identical sets)
INumber of items in both sets
ANumber of distinct items in set A
BNumber of distinct items in set B

The denominator is the number of distinct items in the two sets taken together. Jaccard introduced the measure as the coefficient of community of two districts: the number of plant species common to both, divided by the total number of species in the two, times 100 [1].

Jaccard index from item sets

The calculator removes duplicates, counts the items in each list and the items found in both, and applies the formula above. For set A = apple, banana, cherry, date and set B = Banana, cherry, fig, grape, kiwi, two items are shared out of seven distinct items, so J = 2 ÷ (4 + 5 − 2) = 0.285714, a similarity of 28.5714%. With case-sensitive matching, banana and Banana are different items.

Jaccard index from overlap counts

J = I ÷ (I + a + b)

a is the number of items only in set A and b is the number only in set B, so set A has I + a items and set B has I + b. With 3 shared items, 4 A-only items and 7 B-only items, J = 3 ÷ 14 = 0.214286.

Shared items needed for a target

Imin = ⌈t × (A + B) ÷ (1 + t)⌉

t is the target similarity as a fraction and ⌈ ⌉ rounds up to a whole item. This is the main formula solved for I. Sets of 4 and 5 items need 0.5 × 9 ÷ 1.5 = 3 shared items to reach 50%. The shared count cannot exceed the smaller set, so sets of 4 and 10 items cannot reach 80%, which would need 7 shared items.

Jaccard Distance

D = 1 − J

The Jaccard distance is the share of distinct items that are not shared. For the first example it is 1 − 0.285714 = 0.714286. The calculator also shows the Sørensen–Dice coefficient, 2 × I ÷ (A + B), which is 2 × 2 ÷ 9 = 0.444444 for the same sets.

Limits of This Estimate

  • Items match only when their text is the same after trimming spaces and, by default, lowercasing. There is no stemming, spelling correction or matching of similar words.
  • The index treats each list as a set. How many times an item appears and how important it is play no part.
  • When both sets are empty the union is zero and the calculator returns no result.

Sources

  1. P. Jaccard, The Distribution of the Flora in the Alpine Zone, The New Phytologist 11(2), 1912, pages 37 to 50: coefficient of community as shared species over all species in two districts