本文整理汇总了Python中lifelines.estimation.NelsonAalenFitter.fit方法的典型用法代码示例。如果您正苦于以下问题:Python NelsonAalenFitter.fit方法的具体用法?Python NelsonAalenFitter.fit怎么用?Python NelsonAalenFitter.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lifelines.estimation.NelsonAalenFitter
的用法示例。
在下文中一共展示了NelsonAalenFitter.fit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_smoothing_hazard_with_spike_at_time_0
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_smoothing_hazard_with_spike_at_time_0(self):
T = np.random.binomial(20, 0.7, size=300)
T[np.random.binomial(1, 0.3, size=300).astype(bool)] = 0
naf = NelsonAalenFitter()
naf.fit(T)
df = naf.smoothed_hazard_(bandwidth=0.1)
assert df.iloc[0].values[0] > df.iloc[1].values[0]
示例2: test_naf_plot_cumulative_hazard_bandwith_1
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_naf_plot_cumulative_hazard_bandwith_1(self, block):
data1 = np.random.exponential(5, size=(2000, 1)) ** 2
naf = NelsonAalenFitter()
naf.fit(data1)
naf.plot_hazard(bandwidth=5., iloc=slice(0, 1700))
self.plt.title('test_naf_plot_cumulative_hazard_bandwith_1')
self.plt.show(block=block)
return
示例3: test_smoothing_hazard_nontied
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_smoothing_hazard_nontied(self):
T = np.random.exponential(20, size=300) ** 2
C = np.random.binomial(1, 0.8, size=300)
naf = NelsonAalenFitter()
naf.fit(T, C)
naf.smoothed_hazard_(1.)
naf.fit(T)
naf.smoothed_hazard_(1.)
示例4: test_naf_plot_cumulative_hazard_bandwidth_2
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_naf_plot_cumulative_hazard_bandwidth_2(self):
data1 = np.random.exponential(5, size=(2000, 1))
naf = NelsonAalenFitter()
naf.fit(data1)
naf.plot_hazard(bandwidth=1., ix=slice(0, 7.))
self.plt.title('test_naf_plot_cumulative_hazard_bandwidth_2')
self.plt.show()
return
示例5: test_naf_plot_cumulative_hazard
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_naf_plot_cumulative_hazard(self, block):
data1 = np.random.exponential(5, size=(200, 1))
naf = NelsonAalenFitter()
naf.fit(data1)
ax = naf.plot()
naf.plot_cumulative_hazard(ax=ax, ci_force_lines=True)
self.plt.title("I should have plotted the same thing, but different styles + color!")
self.plt.show(block=block)
return
示例6: test_naf_plotting_with_custom_colours
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_naf_plotting_with_custom_colours(self, block):
data1 = np.random.exponential(5, size=(200, 1))
data2 = np.random.exponential(1, size=(500))
naf = NelsonAalenFitter()
naf.fit(data1)
ax = naf.plot(color="r")
naf.fit(data2)
naf.plot(ax=ax, c="k")
self.plt.title('test_naf_plotting_with_custom_coloirs')
self.plt.show(block=block)
return
示例7: test_naf_plotting_slice
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_naf_plotting_slice(self, block):
data1 = np.random.exponential(5, size=(200, 1))
data2 = np.random.exponential(1, size=(200, 1))
naf = NelsonAalenFitter()
naf.fit(data1)
ax = naf.plot(ix=slice(0, None))
naf.fit(data2)
naf.plot(ax=ax, ci_force_lines=True, iloc=slice(100, 180))
self.plt.title('test_naf_plotting_slice')
self.plt.show(block=block)
return
示例8: get_ipython
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
# In[23]:
get_ipython().magic(u'R p <- plot.ly("https://plot.ly/~rmdk/185/cumulativehazard-vs-time/")')
# pass object to python kernel
get_ipython().magic(u'R -o p')
# Render HTML
HTML(p[0])
# ### Using Python
# In[26]:
from lifelines.estimation import NelsonAalenFitter
naf = NelsonAalenFitter()
naf.fit(T, event_observed=C)
naf.plot(title='Nelson-Aalen Estimate')
# In[27]:
naf.plot(ci_force_lines=True, title='Nelson-Aalen Estimate')
py_p = plt.gcf()
pyplot(py_p, legend=False)
示例9: test_exponential_data_sets_fit
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_exponential_data_sets_fit():
N = 20000
T, C = exponential_survival_data(N, 0.2, scale=10)
naf = NelsonAalenFitter()
naf.fit(T, C).plot()
plt.title("Should be a linear with slope = 0.1")
示例10: test_smoothing_hazard_ties_all_events_observed
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_smoothing_hazard_ties_all_events_observed(self):
T = np.random.binomial(20, 0.7, size=300)
naf = NelsonAalenFitter()
naf.fit(T)
naf.smoothed_hazard_(1.)
示例11: test_smoothing_hazard_ties
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_smoothing_hazard_ties(self):
T = np.random.binomial(20, 0.7, size=300)
C = np.random.binomial(1, 0.8, size=300)
naf = NelsonAalenFitter()
naf.fit(T, C)
naf.smoothed_hazard_(1.)
示例12: test_censor_nelson_aalen
# 需要导入模块: from lifelines.estimation import NelsonAalenFitter [as 别名]
# 或者: from lifelines.estimation.NelsonAalenFitter import fit [as 别名]
def test_censor_nelson_aalen(self, sample_lifetimes):
T, C = sample_lifetimes
naf = NelsonAalenFitter(nelson_aalen_smoothing=False)
naf.fit(T, C)
npt.assert_almost_equal(naf.cumulative_hazard_.values, self.nelson_aalen(T, C))