Skip to content

Commit

Permalink
Basic fix for Jaccard on all zero data (issue #33)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcinnes committed Dec 5, 2017
1 parent a674e0e commit b7ba989
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion umap/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def jaccard(x, y):
num_non_zero += (x_true or y_true)
num_equal += (x_true and y_true)

return float(num_non_zero - num_equal) / num_non_zero
if num_non_zero == 0.0:
return 1.0
else:
return float(num_non_zero - num_equal) / num_non_zero


@numba.njit()
Expand Down

0 comments on commit b7ba989

Please sign in to comment.