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

Warning in kmedoids.fit when using seuclidian metric #113

Closed
jfigui opened this issue Apr 21, 2021 · 6 comments · Fixed by #114
Closed

Warning in kmedoids.fit when using seuclidian metric #113

jfigui opened this issue Apr 21, 2021 · 6 comments · Fixed by #114

Comments

@jfigui
Copy link

jfigui commented Apr 21, 2021

When I use kmedoids.fit() with the 'seuclidian' distance (computed internally by sklearn.metrics.pairwise using scipy.spatial.distance), I get the following warning:

from version 1.0 (renaming of 0.25), pairwise_distances for metric='seuclidean' will require V to be specified if Y is passed.

Should I be worried? Is the metric computed correctly?

Thanks in advance for your time!

@TimotheeMathieu
Copy link
Contributor

This is about scikit-learn sklearn.metrics.pairwise and not about kmedoids.
The metric is computed correctly, it's is just a warning that in the future versions of scikit-learn the standardization coefficient V will not be automatically computed (so your code will not work anymore, an error will be issued), you will have to give the V as an argument.

@jfigui
Copy link
Author

jfigui commented Apr 21, 2021

Thanks for your fast reply.

Yes, strictly speaking it is about sklearn.metrics.pairwise and not kmedoids but how will I be able to pass V as an argument or can V be computed internally by Kmedoids?

@TimotheeMathieu
Copy link
Contributor

Ah, you are right.
There are two solutions that I see

  • you can use the precomputed metric and to compute the distance matrix beforehand.
  • you can give a callable function into metric argument in KMedoids and the callable function would be something like lambda (X,Y): pairwise_distances(X, Y, metric='seuclidean', V=V)

@rth
Copy link
Contributor

rth commented Apr 21, 2021

you can give a callable function into metric argument in KMedoids and the callable function would be something like

I think we should handle this in scikit-learn-extra. So that passing metric='seuclidean' wouldn't raise a warning.

@jfigui
Copy link
Author

jfigui commented Apr 21, 2021

I would be very happy if scikit-learn-extra could take care of that instead of having to do some gimmicks myself.

@jfigui
Copy link
Author

jfigui commented Apr 21, 2021

Thank you so much!

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

Successfully merging a pull request may close this issue.

3 participants