CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.32k stars 551 forks source link

Incorrect datatype in the document for breakpoints parameter : CoxPHFitter is failing with object of type 'int' has no len() #1570

Closed HimanshuBajpai869 closed 8 months ago

HimanshuBajpai869 commented 8 months ago

Hi,

CoxPHFitter is failing with "object of type 'int' has no len()" in case we pass breakpoints as integer.

Code used to fit the model : from lifelines.fitters.coxph_fitter import CoxPHFitter cph = CoxPHFitter(alpha=0.05,penalizer=0.0,l1_ratio=0.0,baseline_estimation_method="piecewise",n_baseline_knots=None,breakpoints=1) cph.fit(final_df_pandas[feature_columns+target_columns+event_column], target_columns[0], event_column[0])

Although in the official document, it is mentioned to pass it as int. However, in the code, we are anticipating the parameters as a List : https://github.com/CamDavidsonPilon/lifelines/blob/10c3538d04cbc3fd9a17b4a3e116b0ae17ddac1a/lifelines/fitters/coxph_fitter.py#L143C9-L143C44

We need to update the documentation here : https://github.com/CamDavidsonPilon/lifelines/blob/10c3538d04cbc3fd9a17b4a3e116b0ae17ddac1a/lifelines/fitters/coxph_fitter.py#L83C7-L83C23

Let me know if I can start the PR for the same.

CamDavidsonPilon commented 8 months ago

Hi @HimanshuBajpai869, yes please provide a PR. Thanks!

HimanshuBajpai869 commented 8 months ago

Hi @CamDavidsonPilon , Looks like I don't have privileges to Publish the feature branch/create PR.

CamDavidsonPilon commented 8 months ago

You should fork the repo, commit your change there, and pull request back to this repo, example

HimanshuBajpai869 commented 8 months ago

Thanks @CamDavidsonPilon ! Started the PR : https://github.com/CamDavidsonPilon/lifelines/pull/1571

HimanshuBajpai869 commented 8 months ago

Thanks @CamDavidsonPilon for merging the PR. The document is updated. Hence closing the ticket.