Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For univariate models:
_hazard
is a property in the object, but actually a function - By making it a function, it becomes a part of the class definition and hence the pickle does not consider it as a property that needs to be serialized.From my manual testing, these fitters can now be pickled:
Also, removed the xfail from the pickle and added joblib test cases in Univariate.
EDIT: I did some more digging and figured out the issue for the Regression models too.
For regression models:
_neg_likelihood_with_penalty_function
is a property in the object, but actually a function. By making it a functools.partial, pickle will know how to pickle it. Also, it needs theunflatten
function which is an autograd function which cannot be pickled. So, we save the data to recreate it with autograd instead of saving the autograd function itself.From my manual testing, these fitters can now be pickled:
And I also added pickle test cases for this, and removed the xfail from joblib test case for Regression models
Fixes #188