當前位置: 首頁>>代碼示例>>Python>>正文


Python NelsonAalenFitter.fit方法代碼示例

本文整理匯總了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]
開發者ID:nerdless,項目名稱:lifelines,代碼行數:9,代碼來源:test_estimation.py

示例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
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例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.)
開發者ID:nerdless,項目名稱:lifelines,代碼行數:10,代碼來源:test_estimation.py

示例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
開發者ID:nerdless,項目名稱:lifelines,代碼行數:10,代碼來源:test_plotting.py

示例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
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例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
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例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
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例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)

開發者ID:RMDK,項目名稱:IPython-plotly,代碼行數:30,代碼來源:survival_analysis.py

示例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")
開發者ID:DGaffney,項目名稱:lifelines,代碼行數:8,代碼來源:test_generate_datasets.py

示例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.)
開發者ID:nerdless,項目名稱:lifelines,代碼行數:7,代碼來源:test_estimation.py

示例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.)
開發者ID:nerdless,項目名稱:lifelines,代碼行數:8,代碼來源:test_estimation.py

示例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))
開發者ID:nerdless,項目名稱:lifelines,代碼行數:7,代碼來源:test_estimation.py


注:本文中的lifelines.estimation.NelsonAalenFitter.fit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。