FIX check that parameters validation happen in fit for KernelPCA#21567
Merged
jjerphan merged 4 commits intoscikit-learn:mainfrom Nov 15, 2021
Merged
FIX check that parameters validation happen in fit for KernelPCA#21567jjerphan merged 4 commits intoscikit-learn:mainfrom
jjerphan merged 4 commits intoscikit-learn:mainfrom
Conversation
adrinjalali
reviewed
Nov 6, 2021
Member
There was a problem hiding this comment.
Since this changes the behavior of the estimator, it would require an entry in the changelog.
It's under doc/whats_new/v1.1.rst
sklearn/decomposition/_kernel_pca.py
Outdated
Comment on lines
435
to
436
| if self.fit_inverse_transform and self.kernel == "precomputed": | ||
| raise ValueError("Cannot fit_inverse_transform with a precomputed kernel.") |
Member
There was a problem hiding this comment.
Please move this validation to the beginning of the fit method, so that it's done before _validate_data.
Member
There was a problem hiding this comment.
Please also make sure this is tested in the test file.
Member
|
Specifically, you need to change the test def test_kernel_pca_invalid_parameters():
"""Check that kPCA raises an error if the parameters are invalid
Tests fitting inverse transform with a precomputed kernel raises a
ValueError.
"""
with pytest.raises(ValueError):
estimator = KernelPCA(n_components=10, fit_inverse_transform=True, kernel="precomputed")
estimator.fit(np.random.randn(10, 10)) |
827f795 to
68a2e76
Compare
jjerphan
requested changes
Nov 13, 2021
Member
There was a problem hiding this comment.
Thank you for this contribution, @MaggieChege.
Some tiny changes can be introduced and this LGTM.
8000
jjerphan
approved these changes
Nov 15, 2021
Member
There was a problem hiding this comment.
Thank you for this contribution, @MaggieChege.
glemaitre
pushed a commit
to glemaitre/scikit-learn
that referenced
this pull request
Nov 22, 2021
…kit-learn#21567) Co-authored-by: ciku <maggie@hellotractor.com>
glemaitre
pushed a commit
to glemaitre/scikit-learn
that referenced
this pull request
8000
Nov 29, 2021
…kit-learn#21567) Co-authored-by: ciku <maggie@hellotractor.com>
samronsin
pushed a commit
to samronsin/scikit-learn
that referenced
this pull request
Nov 30, 2021
…kit-learn#21567) Co-authored-by: ciku <maggie@hellotractor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reference Issues/PRs
Addresses #21406
What does this implement/fix? Explain your changes.
Fix validate parameters in fit for KernelPCA
Any other comments?
#DataUmbrella