KacperKubara / KacperKubara/distython

Small Fix To Make Metric Usable With Both SKLearn's NearestNeighbors & KNNImpute

Open
#9 1 comment 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
Python
Stars
59
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Hi Kacper!

I'm working with a heterogeneous dataset and I was also surprised at the lack of heterogeneous distance variables! The data I was working with had a paper linked to using HEOM as their distance metric. I was about to implement it myself when I luckily stumbled upon your work!

While your algorithms works with algorithms such as NearestNeighbors it doesn't work with sklearn's new imputation feature: [KNN Impute](https://scikit-learn.org/stable/modules/generated/sklearn.impute.KNNImputer.html)

I still consider myself new to Machine Learning, and this is my first time opening an issue on Github, but I implemented a small fix so it works with both the previous algorithms (actually I only tested it on NearestNeighbor implementation, but if it works there then it should work with other algorithms) and SKlearns new feature!

**Issue:**

If you are using a user-defined metric, KNNImpute needs a callable function that takes at least three inputs (instance one, instance two, missing_values)

Taken directly from KNNImpute

"callable : a user-defined function which conforms to the definition of _pairwise_callable(X, Y, metric, **kwds). The function accepts two arrays, X and Y, and a missing_values keyword in kwds and returns a scalar distance value."

Below is what I did to make it work.

![image](https://user-images.githubusercontent.com/59715430/75764211-64ba6680-5cf2-11ea-8a8b-4dc2effbdfc0.png)

![image](https://user-images.githubusercontent.com/59715430/75765038-b3b4cb80-5cf3-11ea-8e56-b050a61b1703.png)

Let me know what you think!

Thanks again for making such a great tool!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.