mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-26 16:51:39 +00:00
handle failing trials (#505)
* handle failing trials * clarify when to return {} * skip ensemble in accuracy check
This commit is contained in:
parent
0bcf618fea
commit
9128c8811a
@ -103,6 +103,10 @@ class BaseTrialRunner:
|
|||||||
trial.set_status(Trial.TERMINATED)
|
trial.set_status(Trial.TERMINATED)
|
||||||
elif self._scheduler_alg:
|
elif self._scheduler_alg:
|
||||||
self._scheduler_alg.on_trial_remove(self, trial)
|
self._scheduler_alg.on_trial_remove(self, trial)
|
||||||
|
if trial.status == Trial.ERROR:
|
||||||
|
self._search_alg.on_trial_complete(
|
||||||
|
trial.trial_id, trial.last_result, error=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SequentialTrialRunner(BaseTrialRunner):
|
class SequentialTrialRunner(BaseTrialRunner):
|
||||||
|
@ -18,6 +18,7 @@ except (ImportError, AssertionError):
|
|||||||
ray_import = False
|
ray_import = False
|
||||||
from .analysis import ExperimentAnalysis as EA
|
from .analysis import ExperimentAnalysis as EA
|
||||||
|
|
||||||
|
from .trial import Trial
|
||||||
from .result import DEFAULT_METRIC
|
from .result import DEFAULT_METRIC
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -154,6 +155,12 @@ def run(
|
|||||||
metric2minimize = (round(config['x'])-95000)**2
|
metric2minimize = (round(config['x'])-95000)**2
|
||||||
time2eval = time.time() - current_time
|
time2eval = time.time() - current_time
|
||||||
tune.report(metric2minimize=metric2minimize, time2eval=time2eval)
|
tune.report(metric2minimize=metric2minimize, time2eval=time2eval)
|
||||||
|
# if the evaluation fails unexpectedly and the exception is caught,
|
||||||
|
# and it doesn't inform the goodness of the config,
|
||||||
|
# return {}
|
||||||
|
# if the failure indicates a config is bad,
|
||||||
|
# report a bad metric value like np.inf or -np.inf
|
||||||
|
# depending on metric mode being min or max
|
||||||
|
|
||||||
analysis = tune.run(
|
analysis = tune.run(
|
||||||
compute_with_config,
|
compute_with_config,
|
||||||
@ -451,7 +458,11 @@ def run(
|
|||||||
result = evaluation_function(trial_to_run.config)
|
result = evaluation_function(trial_to_run.config)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
if isinstance(result, dict):
|
if isinstance(result, dict):
|
||||||
|
if result:
|
||||||
report(**result)
|
report(**result)
|
||||||
|
else:
|
||||||
|
# When the result returned is an empty dict, set the trial status to error
|
||||||
|
trial_to_run.set_status(Trial.ERROR)
|
||||||
else:
|
else:
|
||||||
report(_metric=result)
|
report(_metric=result)
|
||||||
_runner.stop_trial(trial_to_run)
|
_runner.stop_trial(trial_to_run)
|
||||||
|
@ -84,6 +84,7 @@ def test_automl(budget=5, dataset_format="dataframe", hpo_method=None):
|
|||||||
print(automl.resource_attr)
|
print(automl.resource_attr)
|
||||||
print(automl.max_resource)
|
print(automl.max_resource)
|
||||||
print(automl.min_resource)
|
print(automl.min_resource)
|
||||||
|
if budget < performance_check_budget:
|
||||||
automl.fit(X_train=X_train, y_train=y_train, ensemble=True, **settings)
|
automl.fit(X_train=X_train, y_train=y_train, ensemble=True, **settings)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
import pickle
|
import pickle
|
||||||
import shutil
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,6 +308,20 @@ def test_run_training_function_return_value():
|
|||||||
mode="max",
|
mode="max",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Test empty return value
|
||||||
|
def evaluate_config_empty(config):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
tune.run(
|
||||||
|
evaluate_config_empty,
|
||||||
|
config={
|
||||||
|
"x": tune.qloguniform(lower=1, upper=100000, q=1),
|
||||||
|
"y": tune.qlograndint(lower=2, upper=100000, q=2),
|
||||||
|
},
|
||||||
|
num_samples=10,
|
||||||
|
mode="max",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_xgboost_bs():
|
def test_xgboost_bs():
|
||||||
_test_xgboost()
|
_test_xgboost()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user