def _detach_recipe(self, recipe): self.search_space = recipe.search_space() stop = recipe.runtime_params() self.metric_threshold = None if "reward_metric" in stop.keys(): self.mode = Evaluator.get_metric_mode(self.metric) self.metric_threshold = -stop["reward_metric"] if \ self.mode == "min" else stop["reward_metric"] self.epochs = stop["training_iteration"] self.num_samples = stop["num_samples"]
def _validate_metric_mode(metric, mode): if not mode: if callable(metric): raise ValueError( "You must specify `metric_mode` for your metric function") try: from zoo.orca.automl.metrics import Evaluator mode = Evaluator.get_metric_mode(metric) except ValueError: pass if not mode: raise ValueError( f"We cannot infer metric mode with metric name of {metric}. Please" f" specify the `metric_mode` parameter in AutoEstimator.fit()." ) if mode not in ["min", "max"]: raise ValueError("`mode` has to be one of ['min', 'max']") return mode