Repository navigation
DOC Add numerical stability note to CCA when n_features > n_samples - #33791
Open
RudrenduPaul wants to merge 1 commit into
Open
RudrenduPaul wants to merge 1 commit into
RudrenduPaul wants to merge 1 commit into
Conversation
CCA (mode B) uses pseudo-inverse computations which become numerically unstable when n_features > n_samples or n_targets > n_samples — the fitted weights may depend on column order and should not be interpreted. This note was already present as a code comment (line 73-74) but was missing from the public docstring visible to users. Adds a Notes section to the CCA class docstring documenting the instability condition and suggesting PLSCanonical as an alternative, with a reference to the Wegelin review already cited in the source. Fixes scikit-learn#19042 Built by Rudrendu Paul, developed with Claude Code
This branch has not been deployed
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
Fixes #19042
What does this implement/fix? Explain your changes.
CCA (Canonical Correlation Analysis, mode B) uses pseudo-inverse computations internally. These become numerically unstable when
n_features > n_samplesorn_targets > n_samples— the fitted weights may depend on the order of columns inXoryand cannot be interpreted reliably.This instability was already documented as a code comment at line 73–74 of
_pls.py:But it was absent from the public docstring, so users calling
CCAdirectly had no way to discover this limitation without reading the source.This PR adds a
Notessection to theCCAclass docstring documenting:PLSCanonicalas an alternativeDid you add any tests? Why or why not?
No — this is a documentation-only change (a
Notessection added to a docstring). No behavior changes.