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 degree in polynomial kernel should be a floating number #27668
FIX degree in polynomial kernel should be a floating number #27668
Conversation
The SpectralClustering class' parameter `degree` is constrained to positive integers, but the docstring specifies that `degree` can be a float. I've updated the docstring to require that `degree` be passed as an int.
I think the documentation is correct but the code is wrong. The degree will be used by a the polynomial kernel: scikit-learn/sklearn/metrics/pairwise.py Lines 1355 to 1369 in 93fa00c
and this is constrained to be a float. @jeremiedbb I see that I missed this thing in the following review: #24035 We also tolerate an integer at 0 that will be excluded by the kernel itself. I assume that we could fore all the degrees parameter to @jeremiedbb WDYT? |
Interacting IRL with @jeremiedbb, we agreed that this is a regression and that we should use a |
Changed degree type requirement from Integral to Real in SpectralClustering class. This now matches both the SpectralClustering docstring and the expected behaviour of degree, given that it is passed to the polynomial kernel.
Done! Ready for review! |
Can you also update:
In addition, we will need an entry in the changelog to acknowledge the regression. |
…ow/scikit-learn into docs/spectralclustering-degree-type
In the SpectralClustering, KernelPCA and KernelRidge constructors, the degree parameter was modified to allow float values, not just integral values. The respective class' have had their docstrings updated to reflect this change.
Changes complete! Now for
There doesn't seem to be a consistent pattern for integer/float disambiguation in the codebase, for example, in the KernelPCA docstring, both scikit-learn/sklearn/decomposition/_kernel_pca.py Lines 62 to 73 in 4ca0196
|
In this case both integral an float have the same behaviour so there is no need for disambiguation. Sometimes we have float and integral that does not behave the same but usually the range of the accepted values will be different and the parameter validation will be here to help. |
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 only think that we can keep 3 instead of 3.0 since this is already a valid Real.
Otherwise LGTM. Thanks @NolantheNerd
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
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 @NolantheNerd
@NolantheNerd I don't see any conflicts but Github is complaining that there are. Could you kindly check if there are any conflicts with main or otherwise maybe push an empty commit to retrigger the CI? |
@OmarManzoor looks like there was a conflict in the news file. I've fixed the conflict. |
Merging then. Thanks @NolantheNerd |
Reference Issues/PRs
None - this fix is not associated with an issue.
What does this implement/fix? Explain your changes.
This fix only changes the docs.
The SpectralClustering class'
degree
parameter is constrained to positive integers, but the SpectralClustering class' docstring specifies thatdegree
can be a float.I've updated the docstring to require that
degree
be passed as an int.