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

Update cca.py #425

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Update cca.py #425

wants to merge 14 commits into from

Conversation

ricor07
Copy link

@ricor07 ricor07 commented Dec 22, 2024

Rewrote statistic function in cca.py.

Now it outputs similar values to scikitlearn.

For similar i mean values equal up to the third or fourth decimal.

Bug fix: 
given two samples x and y of shape (m, n), statistic(x, y) gave a different output from scikitlearn CCA function
Copy link

netlify bot commented Dec 22, 2024

Deploy Preview for hyppo ready!

Name Link
🔨 Latest commit 3611da3
🔍 Latest deploy log https://app.netlify.com/sites/hyppo/deploys/676abe14604ca50008b383e5
😎 Deploy Preview https://deploy-preview-425--hyppo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ricor07
Copy link
Author

ricor07 commented Dec 23, 2024

Excuse me, the hyppo test fails even with the code that was already there. How can I be sure my modifies are correct or not?

@sampan501
Copy link
Member

Can you write a unit test for your change?

@ricor07
Copy link
Author

ricor07 commented Dec 23, 2024

Done. I don't know if it's what you're looking for

@sampan501
Copy link
Member

Almost perfect. Instead of changing it as you have with unittest, I think it's sufficient to leave the file as is and only modify the oned test with the one you wrote

@sampan501
Copy link
Member

If that is successful, I'll merge

@ricor07
Copy link
Author

ricor07 commented Dec 24, 2024

Good morning. After revising the statistic function, I ran the tests with the original implementation. I observed that 0.07 was not the expected output for a joint_normal(n, 3) distribution with seed 123456789.

`np.random.seed(123456789)
cca_sklearn = CCA_sklearn(1)
cca_hyppo = CCA()

x, y = joint_normal(1000, 3)
print(cca_hyppo.test(x, y), cca_hyppo.statistic(x, y))
print(np.corrcoef(*cca_sklearn.fit_transform(x, y), rowvar=False).diagonal(offset=1)[0])`

Both the hyppo and sklearn methods return the same output, which for n = 1000 is 0.5034560517160103.

I modified the expected statistic values in the tests, and they now pass successfully.

Regarding the errors in the hyppo bot tests, most of them seem to be precision errors. However, as I mentioned earlier, the original CCA code also produced similar errors in these tests, so I am unsure how to proceed.

Please let me know how you would like to address this.

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.80%. Comparing base (bf3c290) to head (3611da3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #425   +/-   ##
=======================================
  Coverage   96.80%   96.80%           
=======================================
  Files          96       96           
  Lines        4476     4476           
=======================================
  Hits         4333     4333           
  Misses        143      143           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ricor07
Copy link
Author

ricor07 commented Dec 24, 2024

Apologies for the disturbance once again. After numerous trials, I was able to identify and resolve the issue with the program. The problem was related to the squaring of values in the initial case. However, during testing, one particular test case failed to produce the correct result. Upon thorough review, I confirmed that the test itself was incorrect and subsequently modified it. Following this correction, all checks now pass successfully. I believe the changes are ready to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants