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

Pickle SR3 and subordinate classes #586

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Jacob-Stevens-Haas
Copy link
Member

@Jacob-Stevens-Haas Jacob-Stevens-Haas commented Dec 20, 2024

Fixes #585

This change moves us away from specifically requiring "weighted" in specifying SR3 regularizer. Previously, much of the weighted functionality had been combined with the unweighted (scalar-weighted) functionality, and all that remained was guard checks for the shape of the weight and data. However, that guard code was added at runtime, making the functions unpickleable (See pickle docs). Some of the solution was to use @wraps. The rest required that we add guard code in a way that was determined at import time, rather than runtime. See commit messages from this PR.

Also includes two quick fixes for a broken scikit-learn version and updating our pre-commit format.

Auto-updated by precommit.
This change adds a test parametrization to specifically check SR3
pickling.

Design-wise, this change shifts away from some of the safety in
argument specifying regularizer.  Weighted regularizers are now
the same in all ways as nonweighted (scalar-weighted) ones.
They already had the same implementation, they just had extra
guard code.

Weight shape is still checked to match data shape in order to
prevent broadcasting, but using a scalar weight on a "weighted"
regularizer is now allowed.
This version introduced the method __sklearn_tags__(),
but it currently seems broken.  Many tests run into calls for:

env\Lib\site-packages\sklearn\utils\_tags.py:396: in get_tags
    tags = estimator.__sklearn_tags__()

E AttributeError: 'super' object has no attribute '__sklearn_tags__'
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.24%. Comparing base (2ca37cb) to head (f60cba9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #586      +/-   ##
==========================================
- Coverage   95.26%   95.24%   -0.02%     
==========================================
  Files          39       39              
  Lines        4099     4105       +6     
==========================================
+ Hits         3905     3910       +5     
- Misses        194      195       +1     

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this debug file be included?

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.

[BUG] can not pickle models with TrappingSR3
2 participants