-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] MNT use check_scalar to validate scalar in SpectralClustering #21881
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
[MRG] MNT use check_scalar to validate scalar in SpectralClustering #21881
Conversation
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!
Please document the change in the changelog for 1.1 (in doc/whats_new/v1.1.rst
).
Hello @ogrisel ! Thank you for your review, I just updated the changelog. |
It looks like there's a bug causing CI to fail (may be fixed in #22049) |
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.
Thank you, @hvassard.
This LGTM after addressing a few suggestions.
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Thank you for your review @jjerphan ! I just updated the code with your suggestions. |
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 your responsiveness, @hvassard.
@pytest.mark.parametrize( | ||
"input, params, err_type, err_msg", | ||
[ | ||
(X, {"n_clusters": -1}, ValueError, "n_clusters == -1, must be >= 1"), | ||
(X, {"n_clusters": 0}, ValueError, "n_clusters == 0, must be >= 1"), | ||
( | ||
X, | ||
{"n_clusters": 1.5}, | ||
TypeError, | ||
"n_clusters must be an instance of <class 'numbers.Integral'>," | ||
" not <class 'float'>", | ||
), | ||
(X, {"n_init": -1}, ValueError, "n_init == -1, must be >= 1"), | ||
(X, {"n_init": 0}, ValueError, "n_init == 0, must be >= 1"), | ||
( | ||
X, | ||
{"n_init": 1.5}, | ||
TypeError, | ||
"n_init must be an instance of <class 'numbers.Integral'>," | ||
" not <class 'float'>", | ||
), | ||
(X, {"gamma": -1}, ValueError, "gamma == -1, must be >= 1"), | ||
(X, {"gamma": 0}, ValueError, "gamma == 0, must be >= 1"), | ||
(X, {"n_neighbors": -1}, ValueError, "n_neighbors == -1, must be >= 1"), | ||
(X, {"n_neighbors": 0}, ValueError, "n_neighbors == 0, must be >= 1"), | ||
( | ||
X, | ||
{"eigen_tol": -1, "eigen_solver": "arpack"}, | ||
ValueError, | ||
"eigen_tol == -1, must be >= 0", | ||
), | ||
(X, {"degree": -1}, ValueError, "degree == -1, must be >= 1"), | ||
(X, {"degree": 0}, ValueError, "degree == 0, must be >= 1"), | ||
], | ||
) |
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.
Thank you for this extensive test!
Reference Issues/PRs
Addresses #20724
#DataUmbrella
What does this implement/fix? Explain your changes.
Summary of changes to SpectralClustering:
Add tests to ensure appropriate behavior when invalid arguments are passed in.
Use the helper function check_scalar from sklearn.utils to validate the scalar parameters.
Progress:
References
Any other comments?
This is my very first contibution to an open source project, please do not hesitate to give me a feedback. Thank you!