Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dice distance #11

Open
ljmartin opened this issue Feb 14, 2020 · 0 comments
Open

Dice distance #11

ljmartin opened this issue Feb 14, 2020 · 0 comments

Comments

@ljmartin
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant