lifelines icon indicating copy to clipboard operation
lifelines copied to clipboard

CoxPHFitter attributes durations and event_observed reorder input indices

Open sam-lupton opened this issue 4 years ago • 2 comments

Shortly before presenting my model, I noticed that the CoxPHFitter() object has a nasty habit. When you use the attributes event_observed and durations (which one expects would be a regular occurrence, in order to pass durations into the predict_survival_function method), they return a random ordering of index, rather than that of the input data passed in.

I doubt that this is expected behaviour, but if it is, it's extremely annoying, because without doing much wrong it can completely randomise and invalidate your results, without the code erroring. I'm not sure why this happens but worth changing the methods to output in the same order as the input!

sam-lupton avatar Oct 13 '21 14:10 sam-lupton

Quite right - this would be surprising for users. I'll rethink why we do this, likely it will change in the next release. Thanks @sam-lupton!

CamDavidsonPilon avatar Oct 13 '21 15:10 CamDavidsonPilon

Thanks @CamDavidsonPilon and cheers for the library - it's a lifesaver in an underdeveloped area 👏

sam-lupton avatar Oct 15 '21 15:10 sam-lupton