Skip to content
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

CCA Incorrect Statistics #413

Open
j1c opened this issue Mar 30, 2024 · 0 comments
Open

CCA Incorrect Statistics #413

j1c opened this issue Mar 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@j1c
Copy link
Member

j1c commented Mar 30, 2024

When d=1, correlation from CCA is same as absolute value of Pearsons. hyppo CCA does not return correct statistic. Similar issues with higher dimensions. I believe it has something to do with squaring of singular values.

Reproducing code example:

import numpy as np
from sklearn.cross_decomposition import CCA as CCA_sklearn
from hyppo.independence import CCA as CCA_hyppo

x = np.random.normal(size=(100, 1))
y = np.random.normal(size=(100, 1))

np.abs(np.corrcoef(x.T, y.T)[0, 1])
>>>> 0.04939641702196

cca_sklearn = CCA_sklearn(1)
np.corrcoef(*cca_sklearn.fit_transform(x, y), rowvar=False).diagonal(offset=1)[0]
>>>> 0.04939641702196002

cca_hyppo = CCA_hyppo()
cca_hyppo.statistic(x, y)
>>>> 0.0024400060146073806
@j1c j1c added the bug Something isn't working label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant