|
3 | 3 | import pathlib
|
4 | 4 | import pickle
|
5 | 5 | import unittest
|
6 |
| -from test.test_api.utils import dummy_do_dummy_prediction, dummy_eval_function, dummy_traditional_classification |
| 6 | +from test.test_api.utils import dummy_do_dummy_prediction, dummy_eval_function |
7 | 7 |
|
8 | 8 | import ConfigSpace as CS
|
9 | 9 | from ConfigSpace.configuration_space import Configuration
|
|
25 | 25 |
|
26 | 26 | from autoPyTorch.api.tabular_classification import TabularClassificationTask
|
27 | 27 | from autoPyTorch.api.tabular_regression import TabularRegressionTask
|
28 |
| -from autoPyTorch.data.tabular_validator import TabularInputValidator |
29 | 28 | from autoPyTorch.datasets.resampling_strategy import (
|
30 | 29 | CrossValTypes,
|
31 | 30 | HoldoutValTypes,
|
32 | 31 | )
|
33 |
| -from autoPyTorch.datasets.tabular_dataset import TabularDataset |
34 | 32 | from autoPyTorch.optimizer.smbo import AutoMLSMBO
|
35 | 33 | from autoPyTorch.pipeline.base_pipeline import BasePipeline
|
36 | 34 | from autoPyTorch.pipeline.components.setup.traditional_ml.traditional_learner import _traditional_learners
|
@@ -575,76 +573,6 @@ def test_portfolio_selection_failure(openml_id, backend, n_samples):
|
575 | 573 | )
|
576 | 574 |
|
577 | 575 |
|
578 |
| -""" |
579 |
| -@pytest.mark.parametrize('dataset_name', ('iris',)) |
580 |
| -@pytest.mark.parametrize('include_traditional', (True, False)) |
581 |
| -def test_get_incumbent_results(dataset_name, backend, include_traditional): |
582 |
| - # TODO: Remove this function completely if possible |
583 |
| - # Get the data and check that contents of data-manager make sense |
584 |
| - X, y = sklearn.datasets.fetch_openml( |
585 |
| - name=dataset_name, |
586 |
| - return_X_y=True, as_frame=True |
587 |
| - ) |
588 |
| -
|
589 |
| - X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( |
590 |
| - X, y, random_state=1) |
591 |
| -
|
592 |
| - # Search for a good configuration |
593 |
| - estimator = TabularClassificationTask( |
594 |
| - backend=backend, |
595 |
| - resampling_strategy=HoldoutValTypes.holdout_validation, |
596 |
| - ) |
597 |
| -
|
598 |
| - InputValidator = TabularInputValidator( |
599 |
| - is_classification=True, |
600 |
| - ) |
601 |
| -
|
602 |
| - # Fit a input validator to check the provided data |
603 |
| - # Also, an encoder is fit to both train and test data, |
604 |
| - # to prevent unseen categories during inference |
605 |
| - InputValidator.fit(X_train=X_train, y_train=y_train, X_test=X_test, y_test=y_test) |
606 |
| -
|
607 |
| - dataset = TabularDataset( |
608 |
| - X=X_train, Y=y_train, |
609 |
| - X_test=X_test, Y_test=y_test, |
610 |
| - validator=InputValidator, |
611 |
| - resampling_strategy=estimator.resampling_strategy, |
612 |
| - resampling_strategy_args=estimator.resampling_strategy_args, |
613 |
| - ) |
614 |
| -
|
615 |
| - pipeline_run_history = RunHistory() |
616 |
| - pipeline_run_history.load_json(os.path.join(os.path.dirname(__file__), '.tmp_api/runhistory.json'), |
617 |
| - estimator.get_search_space(dataset)) |
618 |
| -
|
619 |
| - estimator._do_dummy_prediction = unittest.mock.MagicMock() |
620 |
| -
|
621 |
| - with unittest.mock.patch.object(AutoMLSMBO, 'run_smbo') as AutoMLSMBOMock: |
622 |
| - with unittest.mock.patch.object(TabularClassificationTask, '_do_traditional_prediction', |
623 |
| - new=dummy_traditional_classification): |
624 |
| - AutoMLSMBOMock.return_value = (pipeline_run_history, {}, 'epochs') |
625 |
| - estimator.search( |
626 |
| - X_train=X_train, y_train=y_train, |
627 |
| - X_test=X_test, y_test=y_test, |
628 |
| - optimize_metric='accuracy', |
629 |
| - total_walltime_limit=150, |
630 |
| - func_eval_time_limit_secs=50, |
631 |
| - enable_traditional_pipeline=True, |
632 |
| - load_models=False, |
633 |
| - ) |
634 |
| - config, results = estimator.get_incumbent_results(include_traditional=include_traditional) |
635 |
| - assert isinstance(config, Configuration) |
636 |
| - assert isinstance(results, dict) |
637 |
| -
|
638 |
| - run_history_data = estimator.run_history.data |
639 |
| - costs = [run_value.cost for run_key, run_value in run_history_data.items() if run_value.additional_info is not None |
640 |
| - and (run_value.additional_info['configuration_origin'] != 'traditional' or include_traditional)] |
641 |
| - assert results['opt_loss']['accuracy'] == min(costs) |
642 |
| -
|
643 |
| - if not include_traditional: |
644 |
| - assert results['configuration_origin'] != 'traditional' |
645 |
| -""" |
646 |
| - |
647 |
| - |
648 | 576 | # TODO: Make faster when https://github.com/automl/Auto-PyTorch/pull/223 is incorporated
|
649 | 577 | @pytest.mark.parametrize("fit_dictionary_tabular", ['classification_categorical_only'], indirect=True)
|
650 | 578 | def test_do_traditional_pipeline(fit_dictionary_tabular):
|
|
0 commit comments