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

feat: add sparse PCA #170

Merged
merged 11 commits into from
Jul 18, 2024
Merged

feat: add sparse PCA #170

merged 11 commits into from
Jul 18, 2024

Conversation

nicrie
Copy link
Contributor

@nicrie nicrie commented Jul 16, 2024

Add Sparse PCA using Variable Projection.

Paper: http://arxiv.org/abs/1804.00341
Repository: https://github.com/erichson/ristretto/tree/master/ristretto

PR provides

  • implementation of Sparse PCA
  • tests for basic functionalities
  • basic example in documentation

nicrie added 9 commits July 16, 2024 14:26
Loading submodules via the xeofs package introduces circular imports. Use relative import instead to avoid these cases.
In addition to randomized approach, this alogithm provides an exact solution but suffers computational power. Only useful for small datasets
@nicrie nicrie changed the title Sparse_pca feature: add sparse PCA Jul 16, 2024
@nicrie nicrie changed the title feature: add sparse PCA feat: add sparse PCA Jul 16, 2024
@nicrie
Copy link
Contributor Author

nicrie commented Jul 16, 2024

I'm a bit perplexed as to why ruff is complaining here. The lines it complains about seem to have been tackled by your recent PR #169, specifically by commit 6b275f5.

However inspecting the current code

if type(model) == EOF:
return EOFRotator(**self.params)
elif type(model) == ComplexEOF:
return ComplexEOFRotator(**self.params)
elif type(model) == MCA:
return MCARotator(**self.params)
elif type(model) == ComplexMCA:
it seems that these changes weren't adopted ? Do you know what happened here @slevang ?

EDIT: Nevermind, my bad, you actually updated tests/models/test_eof_rotator.py but ruff complains about xeofs/models/rotator_factory.py. So I'll fix this file here quickly.

nicrie added 2 commits July 16, 2024 18:00
isinstance() caters for inheritance, thus it cannot distinguish between EOF and ComplexEOF model. Instead use type() for comparison.
@slevang
Copy link
Contributor

slevang commented Jul 16, 2024

Not sure exactly why ruff didn't complain before on rotator_factory.py but it looks like E721 was added and stabilized recently. So I assume it is just the difference between latest ruff versions, since we didn't pin the install in the CI check.

@nicrie nicrie marked this pull request as ready for review July 16, 2024 16:39
@nicrie nicrie requested a review from slevang July 16, 2024 16:39
Copy link
Contributor

@slevang slevang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very cool, nice work! I don't have time to dig in right now but will definitely revisit this. At a glance the implementation seems solid.

@nicrie nicrie merged commit e2ccc76 into main Jul 18, 2024
6 checks passed
@nicrie nicrie deleted the sparse_pca branch August 25, 2024 10:24
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