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

Can't pass parameters to weighted_minkowski distance metric #193

Open
Stevod opened this issue Jun 30, 2022 · 3 comments
Open

Can't pass parameters to weighted_minkowski distance metric #193

Stevod opened this issue Jun 30, 2022 · 3 comments

Comments

@Stevod
Copy link

Stevod commented Jun 30, 2022

When I run this code,
index = NNdescent(data = data,
metric = 'weighted_minkowski',
metric_kwds={'p':1}
)
I get an error of no match with getitem. How can I pass this?

Also, I need to pass an array of weights to weight the metric. How can I pass those? By convetring to a dict?

Thanks,
David

@lmcinnes
Copy link
Owner

That should work; I'll see if I can look into it.

@Stevod
Copy link
Author

Stevod commented Jul 1, 2022

Many thanks, as the ability to use different/custom metrics is why I selected the pynndescent package in the first place.

Also, I cannot pass the additional 'w' metric into a custom metric using metric_kwds={'w' : w.to_dict()} as I expected. Could you provide an example of how to do that as well for a custom function.

Much appreciated.
David

@lmcinnes
Copy link
Owner

lmcinnes commented Jul 4, 2022

Due to how things have to get handled by numba, in practice you need to pass all the required arguments in the correct order to the distance function. That means for weighted minkowski you'll have to pass w and p (if you just want to use p you cna always use minkowski instead). To pass w you'll need to pass a vector of length giving the weight for each coordinate.

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

2 participants