python-3.xsummarylifelines

Getting Concordance result of lifelines CoxPH model in a dataframe


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.


Solution

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