def test_aalen_additive_smoothed_plot(self, block): # this is a visual test of the fitting the cumulative # hazards. n = 2500 d = 3 timeline = np.linspace(0, 150, 5000) hz, coef, X = generate_hazard_rates(n, d, timeline) T = generate_random_lifetimes(hz, timeline) + 0.1 * np.random.uniform(size=(n, 1)) C = np.random.binomial(1, 0.8, 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.smoothed_hazards_(1).iloc[0:aaf.cumulative_hazards_.shape[0] - 500].plot() ax.set_xlabel("time") ax.set_title('test_aalen_additive_smoothed_plot') self.plt.show(block=block) return