-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Add input validation to _basePCA.inverse_transform #29310
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
Add input validation to _basePCA.inverse_transform #29310
Conversation
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.
Thanks for the PR @icfaust.
I simplified the validation to only rely on check_array, which deals with empty input.
If the number of components doesn't match, the following operations will fail. With a not as informative error message though, but good enough. I agree that we could have better error messages in that case, but we need to think about it for all estimators, so I leave that for a future issue/PR.
LGTM.
@jeremiedbb hey thanks for getting it ready to go! |
This PR does input checking for PCA's inverse_transform method. If the input array doesn't have the proper number of components, and generic numpy/array_api error is thrown for the dot product for mismatched indices. A check_is_fitted is also added (as is necessary). After this addition, the extracts the necessary checks from self._validate_data, and applies them for the components instead of the features. The check for array namespace is expanded to follow the convention in PCA.transform.
Have added a supporting test.