From 54aab63f751c0ee34b953b671b59a56441fb19eb Mon Sep 17 00:00:00 2001 From: Francisco Rivera Valverde <44504424+franchuterivera@users.noreply.github.com> Date: Wed, 30 Jun 2021 17:48:50 +0200 Subject: [PATCH] [Fix] long running regression (#272) * Fix long running regression * Fix metric append * Remove print * Update autoPyTorch/pipeline/components/training/trainer/__init__.py Co-authored-by: Ravin Kohli <13005107+ravinkohli@users.noreply.github.com> --- .../pipeline/components/training/trainer/__init__.py | 12 ++++++------ cicd/test_preselected_configs.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/autoPyTorch/pipeline/components/training/trainer/__init__.py b/autoPyTorch/pipeline/components/training/trainer/__init__.py index b4221605a..c490a405c 100755 --- a/autoPyTorch/pipeline/components/training/trainer/__init__.py +++ b/autoPyTorch/pipeline/components/training/trainer/__init__.py @@ -249,15 +249,15 @@ def _fit(self, X: Dict[str, Any], y: Any = None, **kwargs: Any) -> 'TrainerChoic ) # Support additional user metrics - additional_metrics = X['additional_metrics'] if 'additional_metrics' in X else None - if 'optimize_metric' in X: - additional_metrics = additional_metrics.append(X['optimize_metric']) if additional_metrics is not None \ - else [X['optimize_metric']] + metrics = get_metrics(dataset_properties=X['dataset_properties']) + if 'additional_metrics' in X: + metrics.extend(get_metrics(dataset_properties=X['dataset_properties'], names=X['additional_metrics'])) + if 'optimize_metric' in X and X['optimize_metric'] not in [m.name for m in metrics]: + metrics.extend(get_metrics(dataset_properties=X['dataset_properties'], names=[X['optimize_metric']])) additional_losses = X['additional_losses'] if 'additional_losses' in X else None self.choice.prepare( model=X['network'], - metrics=get_metrics(dataset_properties=X['dataset_properties'], - names=additional_metrics), + metrics=metrics, criterion=get_loss(X['dataset_properties'], name=additional_losses), budget_tracker=budget_tracker, diff --git a/cicd/test_preselected_configs.py b/cicd/test_preselected_configs.py index 2aa5b0d6b..2638df69d 100644 --- a/cicd/test_preselected_configs.py +++ b/cicd/test_preselected_configs.py @@ -153,7 +153,7 @@ def test_can_properly_fit_a_config(openml_task_id, configuration, scorer, lower_ train_data, target_data = fit_dictionary['backend'].load_datamanager().train_tensors predictions = pipeline.predict(train_data[val_indices]) score = scorer(fit_dictionary['y_train'][val_indices], predictions) - assert pytest.approx(score) >= lower_bound_score + assert score >= lower_bound_score # Check that we reverted to the best score run_summary = pipeline.named_steps['trainer'].run_summary