

def suggest(self, history, searchspace):
    '\n        Suggest params to maximize an objective function based on the\n        function evaluation history using a tree of Parzen estimators (TPE),\n        as implemented in the hyperopt package.\n\n        Use of this function requires that hyperopt be installed.\n        '
    if ('hyperopt' not in sys.modules):
        raise ImportError('No module named hyperopt')
    random = check_random_state(self.seed)
    hp_searchspace = searchspace.to_hyperopt()
    trials = Trials()
    for (i, (params, scores, status)) in enumerate(history):
        if (status == 'SUCCEEDED'):
            result = {
                'loss': (- np.mean(scores)),
                'status': STATUS_OK,
            }
        elif (status == 'PENDING'):
            result = {
                'status': STATUS_RUNNING,
            }
        elif (status == 'FAILED'):
            result = {
                'status': STATUS_FAIL,
            }
        else:
            raise RuntimeError(('unrecognized status: %s' % status))
        vals = {
            
        }
        for var in searchspace:
            if isinstance(var, EnumVariable):
                matches = [i for (i, c) in enumerate(var.choices) if (c == params[var.name])]
                assert (len(matches) == 1)
                vals[var.name] = matches
            else:
                vals[var.name] = [params[var.name]]
        trials.insert_trial_doc({
            'misc': {
                'cmd': ('domain_attachment', 'FMinIter_Domain'),
                'idxs': dict(((k, [i]) for k in hp_searchspace.keys())),
                'tid': i,
                'vals': vals,
                'workdir': None,
            },
            'result': result,
            'tid': i,
            'owner': None,
            'spec': None,
            'state': 2,
            'book_time': None,
            'exp_key': None,
            'refresh_time': None,
            'version': 0,
        })
    trials.refresh()
    chosen_params_container = []

    def mock_fn(x):
        chosen_params_container.append(x)
        return 0
    fmin(fn=mock_fn, algo=tpe.suggest, space=hp_searchspace, trials=trials, max_evals=(len(trials.trials) + 1), **self._hyperopt_fmin_random_kwarg(random))
    chosen_params = chosen_params_container[0]
    return chosen_params

dataset/ETHPy150Open msmbuilder/osprey/osprey/strategies.py HyperoptTPE.suggest/original