def test_fit_args(self): from sklearn.datasets import load_iris from lale.lib.lale import TopKVotingClassifier from lale.lib.sklearn import Nystroem from sklearn.metrics import accuracy_score ensemble = TopKVotingClassifier(estimator=(PCA() | Nystroem()) >> (LogisticRegression()|KNeighborsClassifier()), k=2) trained = ensemble.fit(self.X_train, self.y_train) trained.predict(self.X_test)
def test_fit_smaller_trials(self): from sklearn.datasets import load_iris from lale.lib.lale import TopKVotingClassifier from lale.lib.sklearn import Nystroem from sklearn.metrics import accuracy_score ensemble = TopKVotingClassifier(estimator=(PCA() | Nystroem()) >> (LogisticRegression()|KNeighborsClassifier()), args_to_optimizer={'max_evals':3}, k=20) trained = ensemble.fit(self.X_train, self.y_train) final_ensemble = trained._impl._best_estimator self.assertLessEqual(len(final_ensemble._impl._wrapped_model.estimators), 3)
def test_fit_args(self): from lale.lib.lale import TopKVotingClassifier from lale.lib.sklearn import Nystroem ensemble = TopKVotingClassifier( estimator=(PCA() | Nystroem()) >> (LogisticRegression() | KNeighborsClassifier()), k=2, ) trained = ensemble.fit(self.X_train, self.y_train) trained.predict(self.X_test)
def test_fit_smaller_trials(self): from lale.lib.lale import TopKVotingClassifier from lale.lib.sklearn import Nystroem ensemble = TopKVotingClassifier( estimator=(PCA() | Nystroem()) >> (LogisticRegression() | KNeighborsClassifier()), args_to_optimizer={"max_evals": 3}, k=20, ) trained = ensemble.fit(self.X_train, self.y_train) final_ensemble = trained._impl._best_estimator self.assertLessEqual(len(final_ensemble._impl_instance().estimators), 3)
def test_fit_default_args(self): from sklearn.datasets import load_iris from lale.lib.lale import TopKVotingClassifier from lale.lib.sklearn import Nystroem from sklearn.metrics import accuracy_score with self.assertRaises(ValueError): ensemble = TopKVotingClassifier()
def test_fit_default_args(self): from lale.lib.lale import TopKVotingClassifier with self.assertRaises(ValueError): _ = TopKVotingClassifier()