, duration_col, event_col, entry_col=None)[source]#

Fit the Cox’s proportional hazard for the survival function.

The Cox proportional hazards model (CoxPH) examines the relationship between the survival time of subjects and one or more predictor variables. It models the hazard rate as a product of a baseline hazard function and an exponential function of the predictors, assuming proportional hazards over time.


  • adata (AnnData) – adata: AnnData object with necessary columns duration_col and event_col.

  • duration_col (str) – The name of the column in the AnnData objects that contains the subjects’ lifetimes.

  • event_col (str) – The name of the column in anndata that contains the subjects’ death observation. If left as None, assume all individuals are uncensored.

  • entry_col (str) – Column denoting when a subject entered the study, i.e. left-truncation.

Return type:



Fitted CoxPHFitter.


>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=False)
>>> # Flip 'censor_fl' because 0 = death and 1 = censored
>>> adata[:, ["censor_flg"]].X = np.where(adata[:, ["censor_flg"]].X == 0, 1, 0)
>>> cph =, "mort_day_censored", "censor_flg")