Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
 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()
Пример #6
0
    def test_fit_default_args(self):
        from lale.lib.lale import TopKVotingClassifier

        with self.assertRaises(ValueError):
            _ = TopKVotingClassifier()