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

Add option to regularize linear fits #17

Merged
merged 15 commits into from
Aug 23, 2023
Merged

Add option to regularize linear fits #17

merged 15 commits into from
Aug 23, 2023

Conversation

tyler-a-cox
Copy link
Collaborator

This PR adds the option to regularize linear least squares fits of DPSS and DFT bases to data as is done in dspec.fourier_filter. Regularizing these fits is particularly useful in preventing pop-ups as are seen when fitting DPSS basis vectors to data with wide gaps. Here's an example of using regularizing with the DPSS basis on simulated data with a large gap relative to the filter size.

Screenshot 2023-08-22 at 9 57 15 AM

@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (a4ff591) 98.94% compared to head (5edee2f) 98.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #17      +/-   ##
==========================================
+ Coverage   98.94%   98.96%   +0.02%     
==========================================
  Files           4        4              
  Lines        1700     1738      +38     
==========================================
+ Hits         1682     1720      +38     
  Misses         18       18              
Flag Coverage Δ
unittests 98.96% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
hera_filters/dspec.py 98.18% <100.00%> (+0.02%) ⬆️
hera_filters/tests/test_dspec.py 100.00% <100.00%> (ø)

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

Comment on lines 1015 to 1019
# Compare regularized regression to standard least squares
mdl_reg, res_reg, _ = dspec.fourier_filter(freqs, d, w, [0.], [700e-9], suppression_factors=[0.],
mode='dpss_solve', ridge_alpha=1e-3, eigenval_cutoff=[1e-12])
mdl, res, _ = dspec.fourier_filter(freqs, d, w, [0.], [700e-9], suppression_factors=[0.],
mode='dpss_solve', eigenval_cutoff=[1e-12])
Copy link
Member

Choose a reason for hiding this comment

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

Should we test the other solvers that use ridge alphas?

Copy link
Member

Choose a reason for hiding this comment

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

Specifically matrix and leastsq

Copy link
Member

@jsdillon jsdillon left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks so much!

@jsdillon jsdillon merged commit 5c8c10f into main Aug 23, 2023
7 checks passed
@jsdillon jsdillon deleted the regularizer branch August 23, 2023 20:13
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