bayes_opt.util.UtilityFunction

class bayes_opt.util.UtilityFunction(kind='ucb', kappa=2.576, xi=0, kappa_decay=1, kappa_decay_delay=0)

An object to compute the acquisition functions.

Parameters:
kind : {'ucb', 'ei', 'poi'}

  • ‘ucb’ stands for the Upper Confidence Bounds method

  • ’ei’ is the Expected Improvement method

  • ’poi’ is the Probability Of Improvement criterion.

kappa : float, optional(default=2.576)

Parameter to indicate how closed are the next parameters sampled. Higher value = favors spaces that are least explored. Lower value = favors spaces where the regression function is the highest.

kappa_decay : float, optional(default=1)

kappa is multiplied by this factor every iteration.

kappa_decay_delay : int, optional(default=0)

Number of iterations that must have passed before applying the decay to kappa.

xi : float, optional(default=0.0)

static ei(x, gp, y_max, xi)

Calculate Expected Improvement acqusition function.

Similar to Probability of Improvement (UtilityFunction.poi), but also considers the magnitude of improvement. Calculated as

\[\text{EI}(x) = (\mu(x)-y_{\text{max}} - \xi) \Phi\left( \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right) + \sigma(x) \phi\left( \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right)\]

where \(\Phi\) is the CDF and \(\phi\) the PDF of the normal distribution.

Parameters:
x : np.ndarray

Parameters to evaluate the function at.

gp : sklearn.gaussian_process.GaussianProcessRegressor

A gaussian process regressor modelling the target function based on previous observations.

y_max : number

Highest found value of the target function.

xi : float, positive

Governs the exploration/exploitation tradeoff. Lower prefers exploitation, higher prefers exploration.

Returns:

Values of the acquisition function

static poi(x, gp, y_max, xi)

Calculate Probability of Improvement acqusition function.

Calculated as

\[\text{POI}(x) = \Phi\left( \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right)\]

where \(\Phi\) is the CDF of the normal distribution.

Parameters:
x : np.ndarray

Parameters to evaluate the function at.

gp : sklearn.gaussian_process.GaussianProcessRegressor

A gaussian process regressor modelling the target function based on previous observations.

y_max : number

Highest found value of the target function.

xi : float, positive

Governs the exploration/exploitation tradeoff. Lower prefers exploitation, higher prefers exploration.

Returns:

Values of the acquisition function

static ucb(x, gp, kappa)

Calculate Upper Confidence Bound acquisition function.

Similar to Probability of Improvement (UtilityFunction.poi), but also considers the magnitude of improvement. Calculated as

\[\text{UCB}(x) = \mu(x) + \kappa \sigma(x)\]

where \(\Phi\) is the CDF and \(\phi\) the PDF of the normal distribution.

Parameters:
x : np.ndarray

Parameters to evaluate the function at.

gp : sklearn.gaussian_process.GaussianProcessRegressor

A gaussian process regressor modelling the target function based on previous observations.

y_max : number

Highest found value of the target function.

kappa : float, positive

Governs the exploration/exploitation tradeoff. Lower prefers exploitation, higher prefers exploration.

Returns:

Values of the acquisition function

update_params()

Update internal parameters.

utility(x, gp, y_max)

Calculate acquisition function.

Parameters:
x : np.ndarray

Parameters to evaluate the function at.

gp : sklearn.gaussian_process.GaussianProcessRegressor

A gaussian process regressor modelling the target function based on previous observations.

y_max : number

Highest found value of the target function.

Returns:

Values of the acquisition function