Skip to content

Commit

Permalink
Merge 8a2d62b into 2bc7fce
Browse files Browse the repository at this point in the history
  • Loading branch information
AGMortimer committed Jun 7, 2019
2 parents 2bc7fce + 8a2d62b commit f1d57a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kmodes/util/dissim.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ def calc_dissim(b, X, memj, idr):
if b[idr] == t else 1.0
for idr, t in enumerate(val_a)]).sum(0)
for idj, val_a in enumerate(a)])


def jaccard_dissim(a, b, **_):
"""Jaccard distance function"""
i = np.sum((a == 1) & (b == 1), axis=1)
j = np.sum((a == 1) | (b == 1), axis=1)
if j.any != 0:
return (( j - i ) / j )
else:
return 1

0 comments on commit f1d57a0

Please sign in to comment.