FIX validate parameters in fit for FastICA - #21432
Conversation
thomasjpfan
left a comment
There was a problem hiding this comment.
Small comment on the tests, otherwise LGTM
| w_init = rng.randn(n_features + 1, n_features + 1) | ||
| with pytest.raises(ValueError, match="max_iter should be greater than 1"): | ||
| FastICA(max_iter=0) | ||
| FastICA(max_iter=0).fit(X) |
There was a problem hiding this comment.
To make sure that fit is raised:
fastica = FastICA(max_iter=0)
with pytest.raises(ValueError, match="max_iter should be greater than 1"):
fastica.fit(X)fit for FastICA
|
I think that we should add an entry in the changelog since it could have an effect on third-party libraries. Please add an entry to the change log at - |Fix| :class:`decomposition.FastICA` nows validate input parameters in `fit`
instead of `__init__`.
:pr:`21432` by :user:`Hannah Bohle <hhnnhh>`.It should in the section: :mod:`sklearn.decomposition` |
glemaitre
left a comment
There was a problem hiding this comment.
This should solve the failures in the CI.
| rng = np.random.RandomState(0) | ||
| X = rng.random_sample((n_samples, n_features)) | ||
| w_init = rng.randn(n_features + 1, n_features + 1) | ||
| fastica = FastICA(max_iter=0) |
There was a problem hiding this comment.
fastica is also the name of a function in scikit-learn:
https://scikit-learn.org/stable/modules/generated/fastica-function.html#sklearn.decomposition.fastica
So you need to rename to not have a clash of names:
| fastica = FastICA(max_iter=0) | |
| fastica_estimator = FastICA(max_iter=0) |
| fastica = FastICA(max_iter=0) | ||
| with pytest.raises(ValueError, match="max_iter should be greater than 1"): | ||
| FastICA(max_iter=0) | ||
| fastica.fit(X) |
There was a problem hiding this comment.
| fastica.fit(X) | |
| fastica_estimator.fit(X) |
Co-authored-by: Maren Westermann <[email protected]>
Co-authored-by: Maren Westermann <[email protected]>
Reference Issues/PRs
Addresses #21406
What does this implement/fix? Explain your changes.
Any other comments?
#DataUmbrella