Python 3.x 数据帧中生命线CoxPH模型的一致性结果

Python 3.x 数据帧中生命线CoxPH模型的一致性结果,python-3.x,summary,lifelines,Python 3.x,Summary,Lifelines,我正在使用python中的生命线包的CoxPH实现。目前,结果以表格形式显示在系数和相关统计数据中,并可通过打印摘要()查看。这里有一个例子 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

我正在使用python中的生命线包的CoxPH实现。目前,结果以表格形式显示在系数和相关统计数据中,并可通过打印摘要()查看。这里有一个例子

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]
如何获得数据帧或列表的一致性索引cph.摘要
返回主要结果的数据框,即p值和coef,但不包括一致性指数和其他周围信息。

您可以使用cph访问c指数。一致性指数-如果您愿意,您可以将其放入列表或数据框。

您还可以使用小型脚本在链接中可用。代码如下所示

from lifelines.utils import concordance_index
cph = CoxPHFitter().fit(df, 'T', 'E')
Cindex = concordance_index(df['T'], -cph.predict_partial_hazard(df), df['E'])
此代码将给出C-索引值,该值也与
cph.concordance\u index\uu匹配