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


Python CoxPHFitter.predict_log_hazard_relative_to_mean方法代码示例

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


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

示例1: test_predict_log_hazard_relative_to_mean_without_normalization

# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import predict_log_hazard_relative_to_mean [as 别名]
 def test_predict_log_hazard_relative_to_mean_without_normalization(self, rossi):
     cox = CoxPHFitter(normalize=False)
     cox.fit(rossi, 'week', 'arrest')
     log_relative_hazards = cox.predict_log_hazard_relative_to_mean(rossi)
     means = rossi.mean(0).to_frame().T
     assert cox.predict_partial_hazard(means).values[0][0] != 1.0  
     assert_frame_equal(log_relative_hazards, np.log(cox.predict_partial_hazard(rossi) / cox.predict_partial_hazard(means).squeeze()))
开发者ID:DGaffney,项目名称:lifelines,代码行数:9,代码来源:test_estimation.py

示例2: test_predict_log_hazard_relative_to_mean_with_normalization

# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import predict_log_hazard_relative_to_mean [as 别名]
    def test_predict_log_hazard_relative_to_mean_with_normalization(self, rossi):
        cox = CoxPHFitter(normalize=True)
        cox.fit(rossi, 'week', 'arrest')

        # they are equal because the data is normalized, so the mean of the covarites is all 0,
        # thus exp(beta * 0) == 1, so exp(beta * X)/exp(beta * 0) = exp(beta * X)
        assert_frame_equal(cox.predict_log_hazard_relative_to_mean(rossi), np.log(cox.predict_partial_hazard(rossi)))
开发者ID:DGaffney,项目名称:lifelines,代码行数:9,代码来源:test_estimation.py


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