Skip to content

[WIP] algorithm='auto' should always work for nearest neighbors #7669

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

Closed
wants to merge 2 commits into from

Conversation

maniteja123
Copy link
Contributor

@maniteja123 maniteja123 commented Oct 14, 2016

Solves #4931. Continues work done in #5596

What does this implement/fix? Explain your changes.

'auto' should default to 'brute' when trees do not support the metric.

Any other comments?

Right now, the tests are failing on metric mahalnobis, seuclidean and wminkowski. Please do have a look and let me know if there is any particular reason for the failing tests.

@amueller
Copy link
Member

See #4520 for the discussion for seuclidean, #6915 for mahalanobis, not sure about wminkowski. Also see #4452.

for metric in VALID_METRICS['brute']:
nn = neighbors.NearestNeighbors(n_neighbors=3, algorithm='auto',
metric=metric).fit(X)
assert_true(nn._fit_method, 'brute')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be enough to make sure no error is raised? I don't understand this test. The other metrics might also support this metric.

@amueller
Copy link
Member

These all take additional parameters, so they neither work for the trees or the brute algorithm, right? We might want to remove the distances that require a parameter from VALID_METRICS['brute'], maybe, or we need to add some way to construct them (parallels to #7289).
You can also use yield tests to show all failing tests. Currently I only see mahalanobis in the failing tests, and not cosine which was the one we wanted to fix.

@amueller
Copy link
Member

actually, we should make make the dict from test_neighbors_metrics global to the tests and use the parameters set there.

@maniteja123
Copy link
Contributor Author

Thanks for the review and suggestions @amueller. Will look at those issues and understand it better before doing the changes.

@amueller
Copy link
Member

fixed by #9145.

@amueller amueller closed this Jun 19, 2017
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 this pull request may close these issues.

3 participants