Skip to content

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

@darwin-a

Description

@darwin-a

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

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

image

Let me know what you think!

Thanks again for making such a great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions