turicreate.toolkits.distances.jaccard

turicreate.toolkits.distances.jaccard(x, y)

Compute the Jaccard distance between between two dictionaries. Suppose \(K_x\) and \(K_y\) are the sets of keys from the two input dictionaries.

\[D(x, y) = 1 - \frac{|K_x \cap K_y|}{|K_x \cup K_y|}\]
Parameters:
x : dict

First input dictionary.

y : dict

Second input dictionary.

Returns:
out : float

Jaccard distance between x and y.

Notes

  • Jaccard distance treats the keys in the input dictionaries as sets, and ignores the values in the input dictionaries.

References

Examples

>>> tc.distances.jaccard({'a': 2, 'c': 4}, {'b': 3, 'c': 12})
0.6666666666666667