bayeso.utils.utils_bo

It is utilities for Bayesian optimization.

bayeso.utils.utils_bo.check_hyps_convergence(list_hyps: List[dict], hyps: dict, str_cov: str, fix_noise: bool, ratio_threshold: float = 0.05) → bool

It checks convergence of hyperparameters for Gaussian process regression.

Parameters:
  • list_hyps (list) – list of historical hyperparameters for Gaussian process regression.
  • hyps (dict.) – dictionary of hyperparameters for acquisition function.
  • str_cov (str.) – the name of covariance function.
  • fix_noise (bool.) – flag for fixing a noise.
  • ratio_threshold (float, optional) – ratio of threshold for checking convergence.
Returns:

flag for checking convergence. If converged, it is True.

Return type:

bool.

Raises:

AssertionError

bayeso.utils.utils_bo.check_optimizer_method_bo(str_optimizer_method_bo: str, dim: int, debug: bool) → str

It checks the availability of optimization methods. It helps to run Bayesian optimization, even though additional optimization methods are not installed or there exist the conditions some of optimization methods cannot be run.

Parameters:
  • str_optimizer_method_bo (str.) – the name of optimization method for Bayesian optimization.
  • dim (int.) – dimensionality of the problem we solve.
  • debug (bool.) – flag for printing log messages.
Returns:

available str_optimizer_method_bo.

Return type:

str.

Raises:

AssertionError

bayeso.utils.utils_bo.choose_fun_acquisition(str_acq: str, hyps: dict) → Callable

It chooses and returns an acquisition function.

Parameters:
  • str_acq (str.) – the name of acquisition function.
  • hyps (dict.) – dictionary of hyperparameters for acquisition function.
Returns:

acquisition function.

Return type:

callable

Raises:

AssertionError

bayeso.utils.utils_bo.get_best_acquisition_by_evaluation(initials: numpy.ndarray, fun_objective: Callable) → numpy.ndarray

It returns the best acquisition with respect to values of fun_objective. Here, the best acquisition is a minimizer of fun_objective.

Parameters:
  • initials (numpy.ndarray) – inputs. Shape: (n, d).
  • fun_objective (callable) – an objective function.
Returns:

the best example of initials. Shape: (1, d).

Return type:

numpy.ndarray

Raises:

AssertionError

bayeso.utils.utils_bo.get_best_acquisition_by_history(X: numpy.ndarray, Y: numpy.ndarray) → Tuple[numpy.ndarray, float]

It returns the best acquisition that has shown minimum result, and its minimum result.

Parameters:
  • X (numpy.ndarray) – historical queries. Shape: (n, d).
  • Y (numpy.ndarray) – the observations of X. Shape: (n, 1).
Returns:

a tuple of the best query and its result.

Return type:

(numpy.ndarray, float)

Raises:

AssertionError

bayeso.utils.utils_bo.get_next_best_acquisition(points: numpy.ndarray, acquisitions: numpy.ndarray, points_evaluated: numpy.ndarray) → numpy.ndarray

It returns the next best acquired sample.

Parameters:
  • points (numpy.ndarray) – inputs for acquisition function. Shape: (n, d).
  • acquisitions (numpy.ndarray) – acquisition function values over points. Shape: (n, ).
  • points_evaluated (numpy.ndarray) – the samples evaluated so far. Shape: (m, d).
Returns:

next best acquired point. Shape: (d, ).

Return type:

numpy.ndarray

Raises:

AssertionError