Example #1
0
 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
Example #2
0
 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
Example #3
0
 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
Example #4
0
    def _ask(self, request_number):
        list_of_assignments = []
        for _ in range(request_number):
            optuna_trial = self.study.ask(fixed_distributions=self._get_optuna_search_space())

            assignments = [Assignment(k, v) for k, v in optuna_trial.params.items()]
            list_of_assignments.append(assignments)

            assignments_key = self._get_assignments_key(assignments)
            self.assignments_to_optuna_number[assignments_key].append(optuna_trial.number)

        return list_of_assignments