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

NotImplementedError workaround with PiecewiseExponential and conditional probabilities. #1326

Open
droully opened this issue Sep 15, 2021 · 1 comment

Comments

@droully
Copy link

droully commented Sep 15, 2021

It seems that there is no conditional prediction for the survival function when using PiecewiseExponentialRegressionFitter, is there any workaround using the regular prediction, ie conditional_after=None?

Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_9104/2486616508.py in <module>
      1 censored_subjects_last_obs = test['subscription_age']
----> 2 surv=model.predict_survival_function(test, conditional_after=censored_subjects_last_obs)

~\anaconda3\envs\retention\lib\site-packages\lifelines\fitters\__init__.py in predict_survival_function(self, df, times, conditional_after)
   2287             the survival probabilities of individuals over the timeline
   2288         """
-> 2289         return np.exp(-self.predict_cumulative_hazard(df, times=times, conditional_after=conditional_after))
   2290 
   2291     def predict_median(self, df, *, conditional_after=None) -> pd.DataFrame:

~\anaconda3\envs\retention\lib\site-packages\lifelines\fitters\piecewise_exponential_regression_fitter.py in predict_cumulative_hazard(self, df, times, conditional_after)
    114 
    115         if conditional_after is not None:
--> 116             raise NotImplementedError()
    117 
    118         times = np.atleast_1d(coalesce(times, self.timeline)).astype(float)

NotImplementedError: 
@tyler-keller
Copy link

hi, i'm looking for a similar solution. any updates on this?

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

No branches or pull requests

2 participants