Skip to content

[MRG] Solve the TCA generalized eigenproblem instead of symmetrizing its product - #376

Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
scikit-adaptation:mainfrom
AHMETHAKANBEZIR1:fix/tca-generalized-eigenvectors
Open

AHMETHAKANBEZIR1 wants to merge 1 commit into
scikit-adaptation:mainfrom
AHMETHAKANBEZIR1:fix/tca-generalized-eigenvectors

Conversation

@AHMETHAKANBEZIR1

@AHMETHAKANBEZIR1 AHMETHAKANBEZIR1 commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

TCA passes A^-1 B to numpy.linalg.eigh even though that product is generally non-symmetric (A=I+muKLK, B=KH*K). eigh reads a single triangle, so the fitted directions need not solve the intended eigenproblem. Use scipy.linalg.eigh(B, A) directly and select the largest algebraic eigenvalues. Keep unit Euclidean column norms to retain the previous component-scale convention. The public mu parametrization is preserved and its reciprocal relationship to the paper's ridge is documented rather than silently changed.

Fixes #372. Thanks to VictorBauler for the report and suggested generalized formulation. No other open TCA/eigenvalue PR or issue ownership was found; the separate #371 weights report is not included.

Validation

  • Unmodified main, six new kernel/regularization cases: 4 fail and 2 passing mu=0 controls.

  • Final test_subspace.py: 20 passed, 11 optional-PyTorch skips.

  • Official Minimal CI profile (pytest skada -m "not dataset"): 265 passed, 19 skipped, 98 deselected, 4 xfailed, with existing warnings visible. This is the supported base-dependency profile, not full optional-deep or downloaded-dataset coverage.

  • Full configured pre-commit: all seven hooks pass; installed commit hooks are retained. Diff check passes. Windows checkout line endings were normalized locally; the diff contains only the two intended files.

The regression checks B W = A W Lambda on actual fitted components, leading eigenvalues using an independent Cholesky-whitened ordinary eigensolver, existing unit-column norms and transform consistency. It covers linear and RBF kernels with mu=0,0.1,2. Eigenvector signs are not fixed by the test. This establishes the spectral correction; no improved prediction score on a new dataset is claimed.

Python3.12.14 / NumPy2.5.4 / SciPy1.18.1 / scikit-learn1.9.1 / pandas3.1.0 / POT0.9.7.post1. No new dependency is added: scipy.linalg is already imported. No GPU or optional deep-path claim.

The generalized formulation follows the leading-eigenvector problem in Pan et al., Domain Adaptation via Transfer Component Analysis (2011), section III-C: https://home.cse.ust.hk/~qyang/Docs/2011/05640675.pdf . The existing docstring reference is retained with a narrative explanation of the solver and mu convention.

AI disclosure: the account owner requested OSS contributions. OpenAI Codex performed all technical analysis, implementation, tests and this description; the account owner has not independently reviewed the code. Normal maintainer review is requested; acceptance is not assumed.

Integration check: these three independent PR heads (#376/#377/#378) were applied together to a private worktree based on main 31f2ff8. The official base-dependency Minimal CI profile passed with 273 passed, 21 skipped, 98 deselected and 4 xfailed. The combined scorer/subspace tests and metrics doctest also passed in the separate Torch CPU environment (72 passed). This is a local compatibility check, not an upstream merge or remote-CI result. GitHub Testing workflows currently require maintainer approval.

Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TCA: np.linalg.eigh applied to a non-symmetric matrix

1 participant