当前位置: 首页>>代码示例>>Python>>正文


Python CoxPHFitter.predict_expectation方法代码示例

本文整理汇总了Python中lifelines.estimation.CoxPHFitter.predict_expectation方法的典型用法代码示例。如果您正苦于以下问题:Python CoxPHFitter.predict_expectation方法的具体用法?Python CoxPHFitter.predict_expectation怎么用?Python CoxPHFitter.predict_expectation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lifelines.estimation.CoxPHFitter的用法示例。


在下文中一共展示了CoxPHFitter.predict_expectation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_prediction_methods_respect_index

# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import predict_expectation [as 别名]
    def test_prediction_methods_respect_index(self, data_pred2):
        x = data_pred2[['x1', 'x2']].ix[:3].sort_index(ascending=False)
        expected_index = pd.Index(np.array([3, 2, 1, 0]))

        cph = CoxPHFitter()
        cph.fit(data_pred2, duration_col='t', event_col='E')
        npt.assert_array_equal(cph.predict_partial_hazard(x).index, expected_index)
        npt.assert_array_equal(cph.predict_percentile(x).index, expected_index)
        npt.assert_array_equal(cph.predict_expectation(x).index, expected_index)

        aaf = AalenAdditiveFitter()
        aaf.fit(data_pred2, duration_col='t', event_col='E')
        npt.assert_array_equal(aaf.predict_percentile(x).index, expected_index)
        npt.assert_array_equal(aaf.predict_expectation(x).index, expected_index)
开发者ID:DGaffney,项目名称:lifelines,代码行数:16,代码来源:test_estimation.py

示例2: test_cox_ph_prediction_monotonicity

# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import predict_expectation [as 别名]
    def test_cox_ph_prediction_monotonicity(self, data_pred2):
        # Concordance wise, all prediction methods should be monotonic versions
        # of one-another, unless numerical factors screw it up.
        t = data_pred2['t']
        e = data_pred2['E']
        X = data_pred2[['x1', 'x2']]

        for normalize in [True, False]:
            msg = ("Predict methods should get the same concordance" +
                   " when {}normalizing".format('' if normalize else 'not '))
            cf = CoxPHFitter(normalize=normalize)
            cf.fit(data_pred2, duration_col='t', event_col='E')

            # Base comparison is partial_hazards
            ci_ph = concordance_index(t, -cf.predict_partial_hazard(X).values, e)

            ci_med = concordance_index(t, cf.predict_median(X).ravel(), e)
            assert ci_ph == ci_med, msg

            ci_exp = concordance_index(t, cf.predict_expectation(X).ravel(), e)
            assert ci_ph == ci_exp, msg
开发者ID:nerdless,项目名称:lifelines,代码行数:23,代码来源:test_estimation.py


注:本文中的lifelines.estimation.CoxPHFitter.predict_expectation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。