def test_squared_loss_staged_predict(make_whas500): whas500_data = make_whas500(with_std=False, to_numeric=True) # Test whether staged decision function eventually gives # the same prediction. model = GradientBoostingSurvivalAnalysis(loss="squared", n_estimators=100, max_depth=3, random_state=0) model.fit(whas500_data.x, whas500_data.y) y_pred = model.predict(whas500_data.x) # test if prediction for last stage equals ``predict`` for y in model.staged_predict(whas500_data.x): assert y.shape == y_pred.shape assert_array_equal(y_pred, y) model.set_params(dropout_rate=0.03) model.fit(whas500_data.x, whas500_data.y) y_pred = model.predict(whas500_data.x) # test if prediction for last stage equals ``predict`` for y in model.staged_predict(whas500_data.x): assert y.shape == y_pred.shape assert_array_equal(y_pred, y)
def test_squared_loss_staged_predict(self): # Test whether staged decision function eventually gives # the same prediction. model = GradientBoostingSurvivalAnalysis(loss="squared", n_estimators=100, max_depth=3, random_state=0) model.fit(self.x, self.y) y_pred = model.predict(self.x) # test if prediction for last stage equals ``predict`` for y in model.staged_predict(self.x): self.assertTupleEqual(y.shape, y_pred.shape) assert_array_equal(y_pred, y) model.set_params(dropout_rate=0.03) model.fit(self.x, self.y) y_pred = model.predict(self.x) # test if prediction for last stage equals ``predict`` for y in model.staged_predict(self.x): self.assertTupleEqual(y.shape, y_pred.shape) assert_array_equal(y_pred, y)