def convert(search_space, skopt_suggested): assignments = [] for i in range(len(search_space.params)): param = search_space.params[i] if param.type == INTEGER: assignments.append(Assignment(param.name, skopt_suggested[i])) elif param.type == DOUBLE: assignments.append(Assignment(param.name, skopt_suggested[i])) elif param.type == CATEGORICAL or param.type == DISCRETE: assignments.append(Assignment(param.name, skopt_suggested[i])) return assignments
def convert(search_space, vals): assignments = [] for param in search_space.params: if param.type == INTEGER: assignments.append(Assignment(param.name, int(vals[param.name][0]))) elif param.type == DOUBLE: assignments.append(Assignment(param.name, vals[param.name][0])) elif param.type == CATEGORICAL or param.type == DISCRETE: assignments.append( Assignment(param.name, param.list[vals[param.name][0]])) return assignments
def convert(search_space, chocolate_params): assignments = [] for param in search_space.params: key = BaseChocolateService.encode(param.name) if param.type == INTEGER: assignments.append( Assignment(param.name, chocolate_params[key])) elif param.type == DOUBLE: assignments.append( Assignment(param.name, chocolate_params[key])) elif param.type == CATEGORICAL or param.type == DISCRETE: assignments.append( Assignment(param.name, param.list[chocolate_params[key]])) return assignments
def GetSuggestions(self, request, context): """ Main function to provide suggestion. """ algorithm_name, config = OptimizerConfiguration.convertAlgorithmSpec( request.experiment.spec.algorithm) if algorithm_name != "bayesianoptimization": raise Exception( "Failed to create the algorithm: {}".format(algorithm_name)) if self.is_first_run: search_space = HyperParameterSearchSpace.convert( request.experiment) self.base_service = BaseSkoptService( base_estimator=config.base_estimator, n_initial_points=config.n_initial_points, acq_func=config.acq_func, acq_optimizer=config.acq_optimizer, random_state=config.random_state, search_space=search_space) self.is_first_run = False trials = Trial.convert(request.trials) new_trials = self.base_service.getSuggestions(trials, request.request_number) return api_pb2.GetSuggestionsReply( parameter_assignments=Assignment.generate(new_trials))
def GetSuggestions(self, request, context): """ Main function to provide suggestion. """ base_serice = BaseChocolateService( algorithm_name=request.experiment.spec.algorithm.algorithm_name) search_space = HyperParameterSearchSpace.convert(request.experiment) trials = Trial.convert(request.trials) new_assignments = base_serice.getSuggestions(search_space, trials, request.request_number) return api_pb2.GetSuggestionsReply( parameter_assignments=Assignment.generate(new_assignments))
def GetSuggestions(self, request, context): """ Main function to provide suggestion. """ name, config = OptimizerConfiguration.convertAlgorithmSpec( request.experiment.spec.algorithm) base_serice = BaseHyperoptService( algorithm_name=name, random_state=config.random_state) search_space = HyperParameterSearchSpace.convert(request.experiment) trials = Trial.convert(request.trials) new_assignments = base_serice.getSuggestions( search_space, trials, request.request_number) return api_pb2.GetSuggestionsReply( parameter_assignments=Assignment.generate(new_assignments) )
def GetSuggestions(self, request, context): """ Main function to provide suggestion. """ name, config = OptimizerConfiguration.convert_algorithm_spec( request.experiment.spec.algorithm) if self.is_first_run: search_space = HyperParameterSearchSpace.convert(request.experiment) self.base_service = BaseHyperoptService( algorithm_name=name, algorithm_conf=config, search_space=search_space) self.is_first_run = False trials = Trial.convert(request.trials) new_assignments = self.base_service.getSuggestions(trials, request.request_number) return api_pb2.GetSuggestionsReply( parameter_assignments=Assignment.generate(new_assignments) )