def test_ada_boost_regressor(self): from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split X, y = load_boston(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y) from lale.lib.sklearn import AdaBoostRegressor, DecisionTreeRegressor reg = AdaBoostRegressor(base_estimator = DecisionTreeRegressor()) trained = reg.auto_configure(X_train, y_train, optimizer=Hyperopt, max_evals=1, scoring='r2') #Checking that the inner decision tree does not get the default value for min_samples_leaf, not sure if this will always pass self.assertNotEqual(trained.hyperparams()['base_estimator'].hyperparams()['min_samples_leaf'], 1)
def test_hyperparam_estimator(self): lr = LogisticRegression() linear_reg = LinearRegression() ada = AdaBoostRegressor(base_estimator=lr) replaced_ada = ada.replace(lr, linear_reg) expected_ada = AdaBoostRegressor(base_estimator=linear_reg) self.assertEqual(replaced_ada.to_json(), expected_ada.to_json()) replaced_ada = ada.replace(LogisticRegression, linear_reg) expected_ada = AdaBoostRegressor(base_estimator=linear_reg) self.assertEqual(replaced_ada.to_json(), expected_ada.to_json()) ada_pipeline = PCA >> SimpleImputer >> ada replaced_pipeline = ada_pipeline.replace(lr, linear_reg) expected_pipeline = ( PCA >> SimpleImputer >> AdaBoostRegressor(base_estimator=linear_reg) ) self.assertEqual(replaced_pipeline.to_json(), expected_pipeline.to_json()) ada_choice = PCA | ada replaced_choice = ada_choice.replace(lr, linear_reg) expected_choice = PCA | AdaBoostRegressor(base_estimator=linear_reg) self.assertEqual(replaced_choice.to_json(), expected_choice.to_json()) rfe = RFE(estimator=lr) replaced_rfe = rfe.replace(lr, linear_reg) expected_rfe = RFE(estimator=linear_reg) self.assertEqual(replaced_rfe.to_json(), expected_rfe.to_json())