Dice distance
Opened this issue · 0 comments
ljmartin commented
Hi,
Thankyou for this package !
I'd like to use dice distance. I took a look at how the distances are calculated and it reminded me of the distances in pynndescent - so I think this could be implemented in the same way. See:
https://github.com/lmcinnes/pynndescent/blob/13cf8e0a9f60741e4c1847a5447648fc4c1cae8d/pynndescent/distances.py#L209
i.e.
@numba.njit(fastmath=True, cache=True)
def dice(x, y):
num_true_true = 0.0
num_not_equal = 0.0
for i in range(x.shape[0]):
x_true = x[i] != 0
y_true = y[i] != 0
num_true_true += x_true and y_true
num_not_equal += x_true != y_true
if num_not_equal == 0.0:
return 0.0
else:
return num_not_equal / (2.0 * num_true_true + num_not_equal)
happy to submit a PR but it's not much more than CTRL C CTRL V!