-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
PHReg predicted hazard ratios size do not match with test set size #3178
Comments
Emanuel, Thanks for the report. It looks like this is due to the argument order hr_pred = model.predict(exog=exog[200:], pred_type='hr') Unlike other predicts, in PHReg we allow people to pass in a new endog to @josef-pkt can comment on whether this is bug that needs to be fixed. Kerby |
Dear Kerby, I was expecting exog to be the first argument of the predict function. Indeed, if I specify the argument name then the sizes match. Thank you for your support, |
@josef-pkt I recently ran into this as well. I'm happy to submit a PR updating the parameter order if that's the correct solution |
PHReg has a different order than PHRegResults I think we should fix it in PHRegResults, but we need to find a way to raise a warning about the change in API, i.e. we cannot return silently different numbers if users used And in spite of that warning, all our own examples use exog in predict as positional, so that case falls under backwards compatibility constraints. |
related to deprecation: |
What if we just add a warning now, stating that the behavior is atypical and will change in a future version? |
I started to look at python's |
You just use
And then handle parsing args and kwargs, including warning if needed. Or just make keyword arguments mandatory, which will break calls but is a simple fix, since we are Pyhotn 3.5+ now. As a rule, new, complex functions should require keywords, and we should slowly convert many existing one to use this pattern, so
should be
|
The only way I see right now to find out what has been used as positional and what as keyword arguments is by using a logging decorator, that uses @bashtage Do you know of any cases in other packages like pandas for how to change signature with backwards compatibility constraints? |
@bashtage just using I haven't seen this pattern yet, so will have to look at it. |
If you are only interested in positional inputs you can just intercept args:
can be
so that is
That is the point of the next line in the docstring which has the correct signature. THis is pucked up by numpydoc so that rendered docs are correct, and is shows whenever you |
|
Hi @akravetz Add we need unit test for this to verify which calling versions are allowed and warn or raise. The target is that exog is allowed to be used as positional argument similar to many examples for other models, all other arguments will eventually have to be specified as keyword arguments by the user/caller. |
The prediction of the hazard ratios with the PHReg model is somehow constrained to the size of the train set, is this correct?
I don't see this behaviour in LifeLines python package https://github.com/CamDavidsonPilon/lifelines.
Small working example bellow.
Thank you,
The text was updated successfully, but these errors were encountered: