pynndescent icon indicating copy to clipboard operation
pynndescent copied to clipboard

Add support for nan_euclidean distance metric

Open patcon opened this issue 4 months ago • 2 comments

Really excited to work with this repo! Thanks for all the work, maintainers!

I'm interested in adapting the KNNImputer of sklearn to get some benefit from pynndescent, if possible. It uses a metric it calls nan_euclidean:

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.nan_euclidean_distances.html

Would it be welcome (or even sensible, because maybe there's no benefit here) for someone to submit a PR to bring a version of nan_euclidean into pynndescent?

Thanks!

patcon avatar Aug 30 '25 19:08 patcon

That would definitely make sense to have in pynndescent as an option. I would welcome a PR. It shouldn't be too hard to implement: if you look at how the euclidean (and squared euclidean) distances are implemented you can likely adjust that accordingly for a nan_euclidean version. Beyond that you just need to make sure the named distances dictionaries are updated so that it know which function (or fast alternative) to call given the name "nan_euclidean". Is this something you think you could take on yourself?

lmcinnes avatar Aug 31 '25 19:08 lmcinnes

Thanks Leland! I'm eager to find time to get around to this. Thanks for the encouraging response :)

patcon avatar Aug 31 '25 21:08 patcon