本文整理汇总了Python中lifelines.estimation.CoxPHFitter.print_summary方法的典型用法代码示例。如果您正苦于以下问题:Python CoxPHFitter.print_summary方法的具体用法?Python CoxPHFitter.print_summary怎么用?Python CoxPHFitter.print_summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lifelines.estimation.CoxPHFitter
的用法示例。
在下文中一共展示了CoxPHFitter.print_summary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_print_summary
# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import print_summary [as 别名]
def test_print_summary(self, rossi):
import sys
saved_stdout = sys.stdout
try:
out = StringIO()
sys.stdout = out
cp = CoxPHFitter()
cp.fit(rossi, duration_col='week', event_col='arrest')
cp.print_summary()
output = out.getvalue().strip().split()
expected = """n=432, number of events=114
coef exp(coef) se(coef) z p lower 0.95 upper 0.95
fin -1.897e-01 8.272e-01 9.579e-02 -1.981e+00 4.763e-02 -3.775e-01 -1.938e-03 *
age -3.500e-01 7.047e-01 1.344e-01 -2.604e+00 9.210e-03 -6.134e-01 -8.651e-02 **
race 1.032e-01 1.109e+00 1.012e-01 1.020e+00 3.078e-01 -9.516e-02 3.015e-01
wexp -7.486e-02 9.279e-01 1.051e-01 -7.124e-01 4.762e-01 -2.809e-01 1.311e-01
mar -1.421e-01 8.675e-01 1.254e-01 -1.134e+00 2.570e-01 -3.880e-01 1.037e-01
paro -4.134e-02 9.595e-01 9.522e-02 -4.341e-01 6.642e-01 -2.280e-01 1.453e-01
prio 2.639e-01 1.302e+00 8.291e-02 3.182e+00 1.460e-03 1.013e-01 4.264e-01 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Concordance = 0.640""".strip().split()
for i in [0, 1, 2, -2, -1]:
assert output[i] == expected[i]
finally:
sys.stdout = saved_stdout
示例2: KaplanMeierFitter
# 需要导入模块: from lifelines.estimation import CoxPHFitter [as 别名]
# 或者: from lifelines.estimation.CoxPHFitter import print_summary [as 别名]
kaplen_meier.fit(time_of_event, timeline=time, event_observed=event, label='All patients')
kaplen_meier.plot()
plt.show()
#stratify Congestive Heart Complications
history = df['chf'] == 1;
kaplen_meier = KaplanMeierFitter()
kaplen_meier.fit(time_of_event[history], timeline=time, event_observed=event[history], label='Congestive heart complications')
ax = kaplen_meier.plot()
kaplen_meier.fit(time_of_event[~history], timeline=time, event_observed=event[~history], label='No congestive heart complications')
kaplen_meier.plot(ax=ax, c="b")
plt.show()
#Cox proportional hazard
ph_data = df[["fstat", "lenfol", "bmi", "age"]]
ph = CoxPHFitter()
ph.fit(ph_data, 'lenfol', event_col='fstat')
ph.print_summary()
print(ph.baseline_hazard_.head())
#use predict_survival_function to get probability
x = ph_data[ph_data.columns.difference(['lenfol', 'fstat'])].ix[23:25]
print(x)
ph.predict_survival_function(x).plot()
plt.show()