0

我在 python 中使用 CoxPH 实现生命线包。目前,结果在系数和相关统计数据的表格视图中,可以通过print_summary()看到。这是一个例子

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.summary 返回主要结果的数据框,即 p 值和 coef,但它不包括一致性索引和其他周围信息。

4

2 回答 2

1

您可以使用 - 访问 c-index,cph.concordance_index_如果您愿意,可以将其放入列表或数据框中。

于 2020-06-25T13:20:01.607 回答
0

您还可以使用此链接上提供的小脚本计算 Cox 模型的一致性指数。代码如下。

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-index 值,它也与cph.concordance_index_

于 2020-10-20T10:29:12.330 回答