def test_predict_all_in_regression(self):
     model = AutoML(explain_level=0,
                    verbose=0,
                    random_state=1,
                    results_path=self.automl_dir)
     model.fit(boston.data, boston.target)
     with self.assertRaises(AutoMLException) as context:
         # Try to call predict_all in regression task
         model.predict_all(boston.data)
示例#2
0
    def test_integration(self):
        a = AutoML(results_path=self.automl_dir,
                   mode='Compete',
                   algorithms=['Baseline', 'CatBoost', 'LightGBM', 'Xgboost'],
                   stack_models=True,
                   total_time_limit=60,
                   validation_strategy={
                       "validation_type": "kfold",
                       "k_folds": 3,
                       "shuffle": True,
                       "stratify": True,
                       "random_seed": 123
                   })

        X, y = datasets.make_classification(
            n_samples=1000,
            n_features=30,
            n_informative=29,
            n_redundant=1,
            n_classes=8,
            n_clusters_per_class=3,
            n_repeated=0,
            shuffle=False,
            random_state=0,
        )
        X_train, X_test, y_train, y_test = train_test_split(X,
                                                            y,
                                                            train_size=0.8)

        a.fit(X_train, y_train)
        p = a.predict_all(X_test)

        a2 = AutoML(results_path=self.automl_dir)
        p2 = a2.predict_all(X_test)

        assert_almost_equal(p["prediction_0"].iloc[0],
                            p2["prediction_0"].iloc[0])
        assert_almost_equal(p["prediction_7"].iloc[0],
                            p2["prediction_7"].iloc[0])