def maximize(self, score_optimum=None, realize=True):
"""
Find the next best hyper-parameter setting to optimizer.
Parameters
----------
score_optimum: float
An optional score to use inside the EI formula instead of the optimizer's current_best_score
realize: bool
Whether or not to give a more realistic estimate of the EI (default=True)
Returns
-------
best_setting: dict
The setting with the highest expected improvement
best_score: float
The highest EI (per second)
"""
start = time.time()
# Select a sample of parameters
sampled_params = ParameterSampler(self.param_distributions, self.draw_samples)
# Set score optimum
if score_optimum is None:
score_optimum = self.current_best_score
# Determine the best parameters
best_setting, best_score = self._maximize_on_sample(sampled_params, score_optimum)
if self.local_search:
best_setting, best_score = self._local_search(best_setting, best_score, score_optimum,
max_steps=self.ls_max_steps)
if realize:
best_setting, best_score = self._realize(best_setting, best_score, score_optimum)
# Store running time
running_time = (time.time() - start) / self.simulate_speedup
self.maximize_times.append(running_time)
return best_setting, best_score
评论列表
文章目录