2

Below is the sample code I got from the documentation website. I want to access the baseline hazards and the coefficients of the variates. '''

from lifelines import CoxPHFitter
from lifelines.datasets import load_rossi

rossi_dataset = load_rossi()


#rossi_dataset.head()
cph = CoxPHFitter()
cph.fit(rossi_dataset, duration_col='week', event_col='arrest',)

cph.print_summary()

'''

Cam.Davidson.Pilon
  • 1,606
  • 1
  • 17
  • 31

1 Answers1

2

From the lifelines docs:

To access the coefficients and the baseline hazard directly, you can use params_ and baseline_hazard_ respectively.

from lifelines import CoxPHFitter
from lifelines.datasets import load_rossi

rossi_dataset = load_rossi()


#rossi_dataset.head()
cph = CoxPHFitter()
cph.fit(rossi_dataset, duration_col='week', event_col='arrest',)

print(cph.params_)

print(cph.baseline_survival_)

Cam.Davidson.Pilon
  • 1,606
  • 1
  • 17
  • 31