0

I am using CoxPH implementation of lifelines package in python. Currently, results are in tabular view of coefficients and related stats and can be seen with print_summary(). Here is an example

df = pd.DataFrame({'duration': [4, 6, 5, 5, 4, 6], 
                   'event': [0, 0, 0, 1, 1, 1], 
                   'cat': [0, 1, 0, 1, 0, 1]})

cph = CoxPHFitter()
cph.fit(df, duration_col='duration', event_col='event', show_progress=True)
cph.print_summary()

out[]
[Table of results from print_summary()][1]

How can I get only Concordance index as dataframe or list. cph.summary returns a dataframe of main results i.e. p-values and coef but it does not include concordance index and other surrounding information.

2 Answers2

1

you can access the c-index with cph.concordance_index_ - and you could put this into a list or dataframe if you wish.

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

You can also compute the concordance index for Cox model using a small script available at this link. The code is given below.

from lifelines.utils import concordance_index
cph = CoxPHFitter().fit(df, 'T', 'E')
Cindex = concordance_index(df['T'], -cph.predict_partial_hazard(df), df['E'])

This code will give C-index value, which also matches with cph.concordance_index_