-
-
Notifications
You must be signed in to change notification settings - Fork 550
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 Serialization for UnivariateFitter models #525
Pickle Serialization for UnivariateFitter models #525
Conversation
MRG: Fixes code-block rendering in docs
It passes all tests except a test that simply says "assert false", so I don't think that one is my fault. :) |
@@ -299,6 +300,17 @@ def test_typeerror_is_thrown_if_there_is_nans_in_the_event_col(self, univariate_ | |||
with pytest.raises(TypeError): | |||
fitter().fit(T, E) | |||
|
|||
def test_pickle_serialization(self, positive_sample_lifetimes, univariate_fitters): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -1333,5 +1336,9 @@ def _is_monotonically_decreasing(array): | |||
def next(self): | |||
return self.step_size | |||
|
|||
def _to_array(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah neat, I can use this function elsewhere
First look: really clear pattern, and a nice generalisation of the univariate fitters. |
return self | ||
|
||
def plot_loglogs(self,*args,**kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small lint thing: can you add spaces between these args, and the line below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
TravisCI is pretty red, but you say tests pass locally? |
All except lifelines/tests/test_estimation.py Line 1702 in 0af75fe
|
lgtm, really appreciate this contribution, @dwilson1988! |
Awesome. I needed this, so I hope this works out for everyone else as well! |
FYI I'm hoping to release 0.15 mid-December at the latest, but maybe sooner. Feel free to rip the latest though with Lots of nice changes https://github.com/CamDavidsonPilon/lifelines/blob/17b2931f8e58fc2e4715e3bbcdac00b449bceba9/CHANGELOG.md#0150 |
Essentially I kept with the original design with minor changes. Instead of using factory functions to build the predict/subtract/divide/plot methods, I converted them to base class methods and update the docstrings after fitting. The methods are always present, but raise an exception if fit hasn't been called. Shuffled things around slightly and added a very simple unit test to make sure serialization is working with pickle. Tested on python version 3.6.4, linux.
fixes #524 and #188