-
-
Notifications
You must be signed in to change notification settings - Fork 26k
DOC Added meaning of default=None for n_components in MiniBatchSparsePCA and MiniBatchDictionaryLearning #21428
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
Merged
glemaitre
merged 6 commits into
scikit-learn:main
from
alceballosa:minibatch_sparse_pca-n_components_None
Oct 25, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
41e0e84
Added description for the default=None case of the n_components param…
alceballosa fbebd5f
Merge branch 'main' of https://github.com/scikit-learn/scikit-learn i…
alceballosa 3eddba1
Add the description for the n_components=None case to MiniBatchDictio…
alceballosa 5c12d98
Setting the reference to the number of features back to ``n_features`…
alceballosa a4a72f6
Update _sparse_pca.py
alceballosa ffa9e91
Create _dict_learning.py
alceballosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -762,8 +762,9 @@ def dict_learning_online( | |
X : ndarray of shape (n_samples, n_features) | ||
Data matrix. | ||
|
||
n_components : int, default=2 | ||
Number of dictionary atoms to extract. | ||
n_components : int or None, default=2 | ||
Number of dictionary atoms to extract. If None, then ``n_components`` | ||
is set to ``n_features``. | ||
|
||
alpha : float, default=1 | ||
Sparsity controlling parameter. | ||
|
@@ -1335,8 +1336,9 @@ class DictionaryLearning(_BaseSparseCoding, BaseEstimator): | |
|
||
Parameters | ||
---------- | ||
n_components : int, default=n_features | ||
Number of dictionary elements to extract. | ||
n_components : int, default=None | ||
Number of dictionary elements to extract. If None, then ``n_components`` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the above line is wrong. It should be n_components : int, default=None |
||
is set to ``n_features``. | ||
|
||
alpha : float, default=1.0 | ||
Sparsity controlling parameter. | ||
|
This file contains hidden or 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.
Then we should also correct the line above
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.
Hi @glemaitre: quick question before editing this, since n_components for class DictionaryLearning (line 1338) can take None too, shouldn't the dtype for line 765 be something along the lines of "int or None" too? Or is that unnecessary because the default value being None already states that fact implicitly?
Thank you!
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.
This is exactly the case,
default=None
is already making it implicit. We should only ensure to specify what it means in the docstring that follows (it is indeed what you are doing).We would sometimes mention
None
in the type and as adefault
(e.g.random_state
because the semantic ofNone
is then different in this case).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.
Great, thank you! I just did the relevant edit. Let me know if anything else looks off.