【问题标题】:Getting Concordance result of lifelines CoxPH model in a dataframe在数据框中获取生命线 CoxPH 模型的一致性结果
【发布时间】:2020-06-24 08:06:50
【问题描述】:

我在 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]

我如何才能仅将 Concordance 索引作为数据框或列表。 cph.summary 返回主要结果的数据框,即 p 值和 coef,但不包括一致性索引和其他周边信息。

【问题讨论】:

    标签: python-3.x summary lifelines


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您还可以使用this 链接上的小脚本计算 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_ 匹配

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-12
        • 2017-12-25
        相关资源
        最近更新 更多