bayeso.bo.bo_w_tp

It defines a class of Bayesian optimization with Student-\(t\) process regression.

class bayeso.bo.bo_w_tp.BOwTP(range_X: numpy.ndarray, str_cov: str = 'matern52', str_acq: str = 'ei', normalize_Y: bool = True, use_ard: bool = True, prior_mu: Optional[Callable] = None, str_optimizer_method_tp: str = 'SLSQP', str_optimizer_method_bo: str = 'L-BFGS-B', debug: bool = False)

Bases: bayeso.bo.base_bo.BaseBO

It is a Bayesian optimization class with Student-\(t\) process regression.

Parameters:
  • range_X (numpy.ndarray) – a search space. Shape: (d, 2).
  • str_cov (str., optional) – the name of covariance function.
  • str_acq (str., optional) – the name of acquisition function.
  • normalize_Y (bool., optional) – flag for normalizing outputs.
  • use_ard (bool., optional) – flag for automatic relevance determination.
  • prior_mu (NoneType, or callable, optional) – None, or prior mean function.
  • str_optimizer_method_tp (str., optional) – the name of optimization method for Student-\(t\) process regression.
  • str_optimizer_method_bo (str., optional) – the name of optimization method for Bayesian optimization.
  • debug (bool., optional) – flag for printing log messages.
_abc_impl = <_abc_data object>
_optimize(fun_negative_acquisition: Callable, str_sampling_method: str, num_samples: int) → Tuple[numpy.ndarray, numpy.ndarray]

It optimizes fun_negative_function with self.str_optimizer_method_bo. num_samples examples are determined by str_sampling_method, to start acquisition function optimization.

Parameters:
  • fun_objective (callable) – negative acquisition function.
  • str_sampling_method (str.) – the name of sampling method.
  • num_samples (int.) – the number of samples.
Returns:

tuple of next point to evaluate and all candidates determined by acquisition function optimization. Shape: ((d, ), (num_samples, d)).

Return type:

(numpy.ndarray, numpy.ndarray)

compute_acquisitions(X: numpy.ndarray, X_train: numpy.ndarray, Y_train: numpy.ndarray, cov_X_X: numpy.ndarray, inv_cov_X_X: numpy.ndarray, hyps: dict) → numpy.ndarray

It computes acquisition function values over ‘X’, where X_train, Y_train, cov_X_X, inv_cov_X_X, and hyps are given.

Parameters:
  • X (numpy.ndarray) – inputs. Shape: (l, d) or (l, m, d).
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • cov_X_X (numpy.ndarray) – kernel matrix over X_train. Shape: (n, n).
  • inv_cov_X_X (numpy.ndarray) – kernel matrix inverse over X_train. Shape: (n, n).
  • hyps (dict.) – dictionary of hyperparameters.
Returns:

acquisition function values over X. Shape: (l, ).

Return type:

numpy.ndarray

Raises:

AssertionError

compute_posteriors(X_train: numpy.ndarray, Y_train: numpy.ndarray, X_test: numpy.ndarray, cov_X_X: numpy.ndarray, inv_cov_X_X: numpy.ndarray, hyps: dict) → numpy.ndarray

It returns posterior mean and standard deviation over X_test.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • X_test (numpy.ndarray) – inputs. Shape: (l, d) or (l, m, d).
  • cov_X_X (numpy.ndarray) – kernel matrix over X_train. Shape: (n, n).
  • inv_cov_X_X (numpy.ndarray) – kernel matrix inverse over X_train. Shape: (n, n).
  • hyps (dict.) – dictionary of hyperparameters for Gaussian process.
Returns:

posterior mean and standard deviation over X_test. Shape: ((l, ), (l, )).

Return type:

(numpy.ndarray, numpy.ndarray)

Raises:

AssertionError

optimize(X_train: numpy.ndarray, Y_train: numpy.ndarray, str_sampling_method: str = 'sobol', num_samples: int = 100) → Tuple[numpy.ndarray, dict]

It computes acquired example, candidates of acquired examples, acquisition function values for the candidates, covariance matrix, inverse matrix of the covariance matrix, hyperparameters optimized, and execution times.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • str_sampling_method (str., optional) – the name of sampling method for acquisition function optimization.
  • num_samples (int., optional) – the number of samples.
Returns:

acquired example and dictionary of information. Shape: ((d, ), dict.).

Return type:

(numpy.ndarray, dict.)

Raises:

AssertionError