Skip to content

[MRG] Changed code example for FAQ #7820

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

Conversation

sillystring13
Copy link

Reference Issue

Related to: #7669

What does this implement/fix? Explain your changes.

Problem:
The doc/faq example "How do I deal with string data (or trees, graphs...)?" has a chunk of code that doesn't work if you increase the number of samples.

Fix:
The code example needs the parameter 'algorithm=brute' for the the custom distance metric with data indexing to work correctly. Otherwise, for larger datasets the default 'algorithm=auto' will choose an incompatible algorithm which breaks the custom data indexing.

Any other comments?

Here's a notebook with code demonstrating the issue:
https://github.com/sillystring13/cuddly-barnacle/blob/master/Example%20-%20Sklearn%20FAQ%20code%20test.ipynb

The code example needs the parameter 'algorithm=brute' for the the custom distance metric with data indexing to work correctly.  Otherwise, for larger datasets the default 'algorithm=auto' will choose an incompatible algorithm which breaks the custom data indexing.  

notebook with code demonstrating the issue:
https://github.com/sillystring13/cuddly-barnacle/blob/master/Example%20-%20Sklearn%20FAQ%20code%20test.ipynb
@jnothman
Copy link
Member

jnothman commented Nov 4, 2016

Please add an explanation that without 'brute', the algorithm may assume that the distance is a function of a real-valued (continuous) feature space.

@@ -214,7 +214,7 @@ DBSCAN with Levenshtein distances::
array([[0],
[1],
[2]])
>>> dbscan(X, metric=lev_metric, eps=5, min_samples=2) # doctest: +SKIP
>>> dbscan(X, metric=lev_metric, eps=5, min_samples=2, algorithm='brute') # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

Please split into two lines. Max length 79

@amueller
Copy link
Member

fixed in #11884

@amueller amueller closed this Aug 22, 2018
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