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] Fix n_components kwarg missing in SpectralClustering. See #13698 #13726
Merged
Merged
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4e1cb1c
add n_components as instance variable
fdas3213 5323ca0
test SpectralClustering object access n_components
fdas3213 727f2a4
called fit function to access n_components
fdas3213 e71b4c5
fixed assertion error
fdas3213 fb12eff
fix doctest failure
fdas3213 6468bdf
do not modify value of self.n_components
fdas3213 8089b72
Merge remote-tracking branch 'upstream/master'
fdas3213 867b7b2
Merge remote-tracking branch 'upstream/master'
fdas3213 81834c5
fix doctest error
fdas3213 ade380f
Merge remote-tracking branch 'upstream/master'
fdas3213 9098b4b
Merge remote-tracking branch 'upstream/master'
fdas3213 16f034b
add brief test
fdas3213 ee6dde2
changed n_components to 1
fdas3213 8a70366
fix assertion error
fdas3213 179b35d
Merge remote-tracking branch 'upstream/master'
fdas3213 776fed9
Merge remote-tracking branch 'upstream/master'
fdas3213 cbe3a16
add entry to change log
fdas3213 3b829a8
change fix to enhancement
fdas3213 ce1c3cb
Update v0.22.rst
jnothman File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Sure. Should I add the test as
def test_n_components
in test_spectral.py?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.
Yes, please!
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.
To test that n_components is equivalent to n_clusters by default, I need to initialize the value of n_components in
__init__
asself.n_components = n_clusters if n_components is None else n_components
.However, this would lead to Assertion error that happens at the last line
assert param_value == init_param.default, init_param.name
incheck_parameters_default_constructible
in sklearn/utils/estimator_checks.py becauseparam_value = n_clusters
if n_components is None, butinit_param.default = None
, and becausen_clusters != None
, this error occurs.As thomasjpfan suggested, I "Set
self.n_components = n_components
and passself.n_components
directly tospectral_clustering
without modifying any of the parameters in__init__
. " But in this way, I cannot testn_components
is equivalent ton_clusters
by default, sinceself.n_components = None
andself.n_clusters = n_clusters
.Any suggestion on this? Thank you