Ejemplo n.º 1
0
 def test_left_censorship_cdf_plots(self, block):
     df = load_nh4()
     fig, axes = self.plt.subplots(2, 2, figsize=(9, 5))
     axes = axes.reshape(4)
     for i, model in enumerate([WeibullFitter(), LogNormalFitter(), LogLogisticFitter(), ExponentialFitter()]):
         model.fit_left_censoring(df["NH4.mg.per.L"], ~df["Censored"])
         ax = cdf_plot(model, ax=axes[i])
         assert ax is not None
     self.plt.suptitle("test_left_censorship_cdf_plots")
     self.plt.show(block=block)
Ejemplo n.º 2
0
 def test_right_censorship_cdf_plots(self, block):
     df = load_rossi()
     fig, axes = self.plt.subplots(2, 2, figsize=(9, 5))
     axes = axes.reshape(4)
     for i, model in enumerate([WeibullFitter(), LogNormalFitter(), LogLogisticFitter(), ExponentialFitter()]):
         model.fit(df["week"], df["arrest"])
         ax = cdf_plot(model, ax=axes[i])
         assert ax is not None
     self.plt.suptitle("test_right_censorship_cdf_plots")
     self.plt.show(block=block)
Ejemplo n.º 3
0
T = np.where(ix == 3, np.maximum(T, MIN_3), T)
E = T_actual == T

fig, axes = plt.subplots(2, 2, figsize=(9, 5))
axes = axes.reshape(4)

for i, model in enumerate([
        WeibullFitter(),
        KaplanMeierFitter(),
        LogNormalFitter(),
        LogLogisticFitter()
]):
    if isinstance(model, KaplanMeierFitter):
        model.fit_left_censoring(T, E, label=model.__class__.__name__)
    else:
        model.fit_left_censoring(T, E, label=model.__class__.__name__)

    model.plot_cumulative_density(ax=axes[i])
plt.tight_layout()

for i, model in enumerate(
    [WeibullFitter(), LogNormalFitter(),
     LogLogisticFitter()]):
    model.fit_left_censoring(T, E)
    fig, axes = plt.subplots(2, 1, figsize=(8, 6))

    cdf_plot(model, ax=axes[0])
    qq_plot(model, ax=axes[1])

plt.show()