-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
FIX Allow for KMean's attributes to be readonly #24258
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
FIX Allow for KMean's attributes to be readonly #24258
Conversation
ogrisel
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.
LGTM, thanks for the fix.
Can you please just update the docstrings of lloyd_iter_chunked_dense and lloyd_iter_chunked_sparse to make it explicit that centers_new and centers_squared_norms can be left to None if update_centers is False?
ogrisel
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 meant to give my approval instead of just a comment in the above review.
|
@jjerphan @jeremiedbb or @fcharras might be interested in giving this PR a second look. |
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.
LGTM. Thank you for fixing this issue.
Side note: I think the new test in this PR for read only attributes can become a common test.
I am OK making the test a common test. IMO, this can be done as part of this PR.
Side note: we recently discovered that some part of the routines can be simplified, see: #24262
Co-authored-by: Julien Jerphanion <[email protected]>
jeremiedbb
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.
LGTM as well after this comment #24258 (review) is addressed
|
Updated PR with:
|
Co-authored-by: Julien Jerphanion <[email protected]>
Reference Issues/PRs
Fixes #24253
What does this implement/fix? Explain your changes.
This PR allows for the attributes for KMeans to be read-only. When
update_centers=False,lloyd_iter_chunked_densedoes not actually updatecenters_new. This is the case whenKMeans.predictends up calling_labels_inertia:scikit-learn/sklearn/cluster/_kmeans.py
Line 808 in feaf382
Any other comments?
Side note: I think the new test in this PR for read only attributes can become a common test.