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


Python AalenAdditiveFitter.smoothed_hazards_方法代码示例

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


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

示例1: test_aalen_additive_smoothed_plot

# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import smoothed_hazards_ [as 别名]
    def test_aalen_additive_smoothed_plot(self, block):
        # this is a visual test of the fitting the cumulative
        # hazards.
        n = 2500
        d = 3
        timeline = np.linspace(0, 150, 5000)
        hz, coef, X = generate_hazard_rates(n, d, timeline)
        T = generate_random_lifetimes(hz, timeline) + 0.1 * np.random.uniform(size=(n, 1))
        C = np.random.binomial(1, 0.8, size=n)
        X['T'] = T
        X['E'] = C

        # fit the aaf, no intercept as it is already built into X, X[2] is ones
        aaf = AalenAdditiveFitter(coef_penalizer=0.1, fit_intercept=False)
        aaf.fit(X, 'T', 'E')
        ax = aaf.smoothed_hazards_(1).iloc[0:aaf.cumulative_hazards_.shape[0] - 500].plot()
        ax.set_xlabel("time")
        ax.set_title('test_aalen_additive_smoothed_plot')
        self.plt.show(block=block)
        return
开发者ID:,项目名称:,代码行数:22,代码来源:


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