def test_predict_batched(self): cs = SimpleRegressionPipeline.get_hyperparameter_search_space() default = cs.get_default_configuration() cls = SimpleRegressionPipeline(default) X_train, Y_train, X_test, Y_test = get_dataset(dataset='boston') cls.fit(X_train, Y_train) X_test_ = X_test.copy() prediction_ = cls.predict(X_test_) cls_predict = mock.Mock(wraps=cls.pipeline_) cls.pipeline_ = cls_predict prediction = cls.predict(X_test, batch_size=20) self.assertEqual((356,), prediction.shape) self.assertEqual(18, cls_predict.predict.call_count) assert_array_almost_equal(prediction_, prediction)
def test_predict_batched(self): cs = SimpleRegressionPipeline.get_hyperparameter_search_space( include={'regressor': ['decision_tree']}) default = cs.get_default_configuration() cls = SimpleRegressionPipeline(default) X_train, Y_train, X_test, Y_test = get_dataset(dataset='diabetes') cls.fit(X_train, Y_train) X_test_ = X_test.copy() prediction_ = cls.predict(X_test_) cls_predict = unittest.mock.Mock(wraps=cls.pipeline_) cls.pipeline_ = cls_predict prediction = cls.predict(X_test, batch_size=20) self.assertEqual((292, ), prediction.shape) self.assertEqual(15, cls_predict.predict.call_count) assert_array_almost_equal(prediction_, prediction)