-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Fitting a NearestNeighbors model fails with sparse input and a callable as metric #9199
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
Comments
I think this may be fixed in master due to #9145 |
B |
Please check |
I just cloned
VersionsDarwin-15.6.0-x86_64-i386-64bit |
A very simple fix would be to change Line 214 in
to
|
:( Sorry we didn't fix this in the previous patch.
Pull request welcome, with a test.
…On 23 June 2017 at 06:12, Thomas ***@***.***> wrote:
A very simple fix would be to change Line 214
<https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/neighbors/base.py#L214>
in sklearn/neighbors/base.py
<https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/neighbors/base.py>
from
if self.effective_metric_ not in VALID_METRICS_SPARSE['brute']:
to
if not callable(self.effective_metric_) and self.effective_metric_ not in VALID_METRICS_SPARSE['brute']:
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#9199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz61byWrAlsjvZAS7YUkKtVfq08pZ9ks5sGsqRgaJpZM4OCQLN>
.
|
Cool, I'll submit a PR along with a test for it. |
@tttthomasssss have you fixed this bug? |
No pull request yet |
@taineleau @jnothman thanks for the reminder and apologies for the delay! I have a fix for the problem per se, however haven't gotten round to write an appropriate test for it. I will submit a PR within the next few days. |
Hope you fix it soon! Thanks!!!!!
…On Wed, Aug 16, 2017 at 4:40 AM, Thomas ***@***.***> wrote:
@taineleau <https://github.com/taineleau> @jnothman
<https://github.com/jnothman> thanks for the reminder and apologies for
the delay!
I have a fix for the problem *per se*, however haven't gotten round to
write an appropriate test for it.
I will submit a PR within the next few days.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGKWDmMRQZIUF4kMa2iVjyBxT8997sxFks5sYqsEgaJpZM4OCQLN>
.
--
Danlu Chen
Homepage: https://taineleau.me
|
…ghbors model fails with sparse input and a callable as metric
…ils with sparse input and a callable as metric (scikit-learn#9579)
Description
Fitting a
NearestNeighbors
model fails when a) the distancemetric
used is acallable
and b) the input to theNearestNeighbors
model is sparse.Steps/Code to Reproduce
Expected Results
No error is thrown when passing a callable as metric with sparse input
Actual Results
Some Analysis/Wild Speculation
The problem seems to come from the fact that in the case of sparse input, it is only checked whether the given metric is in the list of metrics accepting sparse input, but no check is made whether the given metric is a string or a callable: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/neighbors/base.py#L210
Versions
The text was updated successfully, but these errors were encountered: