-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
[BUG] Optics float min_samples NN instantiation #14421
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
[BUG] Optics float min_samples NN instantiation #14421
Conversation
|
thanks for spotting this |
|
Where shall the what's new go? (this PR, the commit message, ...)? Actually it's just the expected behavior, given the documentation Regarding the test: Advise is very welcome! |
3d0fbf8 to
f68dead
Compare
qinhanmin2014
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, please try to avoid irrelevant changes, this will make this PR much easier to review.
Please add an entry to the change log at |
f68dead to
77a9a10
Compare
|
ping we you are ready for another review. please avoid irrelevant changes. |
When passing min_samples as a float to optics l439 & 440 execute to bring it into integer ranges, but don't convert to int:
```
if min_samples <= 1:
min_samples = max(2, min_samples * n_samples) # Still a float
```
When instantiating the NearestNeighbours class with a float it raises due to the float (l448).
Fix:
```
if min_samples <= 1:
min_samples = int(round(max(2, min_samples * n_samples))) # round to get the closest integer
```
the int(...) is for backwards compatibbility to Python 2 where `round: T -> T` with T Number, while Python3 `round: T -> int`
77a9a10 to
a1d5e34
Compare
|
Just added the what's new part, ready for review |
|
ping |
rth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into it !
SomeUserName1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrated changes
rth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, otherwise LGTM.
|
Also please resolve conflicts. |
Co-Authored-By: Roman Yurchak <[email protected]>
|
@SomeUserName1, are you able to respond to the reviews to complete this work? We would like to include it in 0.21.3 which should be released next week. |
|
Have a presentation tomorrow concerning my bachelor's. |
|
We're going to be releasing 0.21.3 in the coming week, so an update here would be great. |
03f0048 to
87e6ace
Compare
|
Updated |
87e6ace to
7ed1a77
Compare
7ed1a77 to
e4ef829
Compare
jnothman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise lgtm
| C3 = [[100, 100], [100, 96], [100, 106]] | ||
| X = np.vstack((C1, C2, C3)) | ||
|
|
||
| expected_labels = np.r_[[0] * 3, [1] * 3, [2] * 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the point is to test the equivalence between float and int values, then you should be comparing the results of different OPTICS ruins to each other rather than compare to a ground truth again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to introduce a new test for 0.21.3, I think we can make use of existing tests.
qinhanmin2014
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that there're still lots of irrelevant changes. I'm going to open a small PR to finish this one because we're going to release very soon. I'll mention the contributor in what's new. Apologies if I make someone unhappy.
| ``tol`` required too strict types. :pr:`14092` by | ||
| :user:`Jérémie du Boisberranger <jeremiedbb>`. | ||
|
|
||
| :mod:`sklearn.cluster` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have this section
| return size | ||
| elif 0 < size <= 1: | ||
| return max(2, int(size * n_samples)) | ||
| else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep this function as it is and add int when needed?
| C3 = [[100, 100], [100, 96], [100, 106]] | ||
| X = np.vstack((C1, C2, C3)) | ||
|
|
||
| expected_labels = np.r_[[0] * 3, [1] * 3, [2] * 3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to introduce a new test for 0.21.3, I think we can make use of existing tests.
Reference Issues/PRs
None yet.
What does this implement/fix? Explain your changes.
When passing min_samples as a float to optics l439 & 440 execute to bring it into integer ranges, but don't convert to int:
When instantiating the NearestNeighbours class with a float it raises due to the float (l448).
Error message:
Fix:
the int(...) is for backwards compatibbility to Python 2 where
round: T -> Twith T Number, while Python3round: T -> intAny other comments?