

def best_models(self, nb_models, model, data, max_evals):
    trials_list = self.compute_trials(model, data, max_evals)
    num_trials = sum((len(trials) for trials in trials_list))
    if (num_trials < nb_models):
        nb_models = len(trials)
    scores = []
    for trials in trials_list:
        scores = (scores + [trial.get('result').get('loss') for trial in trials])
    cut_off = sorted(scores, reverse=True)[(nb_models - 1)]
    model_list = []
    for trials in trials_list:
        for trial in trials:
            if (trial.get('result').get('loss') >= cut_off):
                model = model_from_yaml(trial.get('result').get('model'))
                model.set_weights(pickle.loads(trial.get('result').get('weights')))
                model_list.append(model)
    return model_list

dataset/ETHPy150Open maxpumperla/elephas/elephas/hyperparam.py HyperParamModel.best_models/original