本文整理汇总了Python中lifelines.estimation.AalenAdditiveFitter.plot方法的典型用法代码示例。如果您正苦于以下问题:Python AalenAdditiveFitter.plot方法的具体用法?Python AalenAdditiveFitter.plot怎么用?Python AalenAdditiveFitter.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lifelines.estimation.AalenAdditiveFitter
的用法示例。
在下文中一共展示了AalenAdditiveFitter.plot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_aaf_panel_dataset
# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import plot [as 别名]
def test_aaf_panel_dataset(self):
matplotlib = pytest.importorskip("matplotlib")
from matplotlib import pyplot as plt
panel_dataset = load_panel_test()
aaf = AalenAdditiveFitter()
aaf.fit(panel_dataset, id_col='id', duration_col='t', event_col='E')
aaf.plot()
示例2: test_aaf_panel_dataset
# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import plot [as 别名]
def test_aaf_panel_dataset(self, block):
panel_dataset = load_panel_test()
aaf = AalenAdditiveFitter()
aaf.fit(panel_dataset, id_col='id', duration_col='t', event_col='E')
aaf.plot()
self.plt.title("test_aaf_panel_dataset")
self.plt.show(block=block)
return
示例3: test_aalen_additive_fit_with_censor
# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import plot [as 别名]
def test_aalen_additive_fit_with_censor(self):
# this is a visual test of the fitting the cumulative
# hazards.
matplotlib = pytest.importorskip("matplotlib")
from matplotlib import pyplot as plt
n = 2500
d = 6
timeline = np.linspace(0, 70, 10000)
hz, coef, X = generate_hazard_rates(n, d, timeline)
X.columns = coef.columns
cumulative_hazards = pd.DataFrame(cumulative_integral(coef.values, timeline),
index=timeline, columns=coef.columns)
T = generate_random_lifetimes(hz, timeline)
X['T'] = T
X['E'] = np.random.binomial(1, 0.99, n)
aaf = AalenAdditiveFitter()
aaf.fit(X, 'T', 'E')
for i in range(d + 1):
ax = plt.subplot(d + 1, 1, i + 1)
col = cumulative_hazards.columns[i]
ax = cumulative_hazards[col].ix[:15].plot(legend=False, ax=ax)
ax = aaf.plot(ix=slice(0, 15), ax=ax, columns=[col], legend=False)
plt.show()
示例4: test_aalen_additive_plot
# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import plot [as 别名]
def test_aalen_additive_plot(self, block):
# this is a visual test of the fitting the cumulative
# hazards.
n = 2500
d = 3
timeline = np.linspace(0, 70, 10000)
hz, coef, X = generate_hazard_rates(n, d, timeline)
T = generate_random_lifetimes(hz, timeline)
C = np.random.binomial(1, 1., 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.plot(iloc=slice(0, aaf.cumulative_hazards_.shape[0] - 100))
ax.set_xlabel("time")
ax.set_title('test_aalen_additive_plot')
self.plt.show(block=block)
return
示例5: test_aalen_additive_fit_no_censor
# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import plot [as 别名]
def test_aalen_additive_fit_no_censor(self, block):
n = 2500
d = 6
timeline = np.linspace(0, 70, 10000)
hz, coef, X = generate_hazard_rates(n, d, timeline)
X.columns = coef.columns
cumulative_hazards = pd.DataFrame(cumulative_integral(coef.values, timeline),
index=timeline, columns=coef.columns)
T = generate_random_lifetimes(hz, timeline)
X['T'] = T
X['E'] = np.random.binomial(1, 1, n)
aaf = AalenAdditiveFitter()
aaf.fit(X, 'T', 'E')
for i in range(d + 1):
ax = self.plt.subplot(d + 1, 1, i + 1)
col = cumulative_hazards.columns[i]
ax = cumulative_hazards[col].loc[:15].plot(legend=False, ax=ax)
ax = aaf.plot(loc=slice(0, 15), ax=ax, columns=[col], legend=False)
self.plt.title("test_aalen_additive_fit_no_censor")
self.plt.show(block=block)
return