Skip to content

Commit

Permalink
fix(ssr): Include full model in model selection list.
Browse files Browse the repository at this point in the history
Also, hack SSR through tests that provide single-feature data in the same
way that trapping was handled.
  • Loading branch information
Jacob-Stevens-Haas committed Oct 16, 2024
1 parent 9b5130a commit 4d27145
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pysindy/optimizers/ssr.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ def _reduce(self, x, y):
" ... {: >10} ... {: >10}".format(*row)
)

self.history_ = []
self.err_history_ = []
self.history_ = [coef]
self.err_history_ = [
np.sum((y - x @ coef.T) ** 2) + l0_penalty * np.count_nonzero(coef)
]
for k in range(self.max_iter):
for i in range(n_targets):
if self.criteria == "coefficient_value":
Expand Down
2 changes: 2 additions & 0 deletions test/test_optimizers/test_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def _align_optimizer_and_1dfeatures(
if isinstance(opt, TrappingSR3):
opt = TrappingSR3(_n_tgts=1, _include_bias=False)
features = np.hstack([features, features])
elif isinstance(opt, SSR):
features = np.hstack([features, features])
else:
features = features
return opt, features
Expand Down

0 comments on commit 4d27145

Please sign in to comment.