bayeso.bo.base_bo

It defines an abstract class of Bayesian optimization.

class bayeso.bo.base_bo.BaseBO(range_X: numpy.ndarray, str_surrogate: str, str_acq: str, str_optimizer_method_bo: str, normalize_Y: bool, debug: bool)

Bases: abc.ABC

It is a Bayesian optimization class.

Parameters:
  • range_X (numpy.ndarray) – a search space. Shape: (d, 2).
  • str_surrogate (str.) – the name of surrogate model.
  • str_acq (str.) – the name of acquisition function.
  • str_optimizer_method_bo (str.) – the name of optimization method for Bayesian optimization.
  • normalize_Y (bool.) – flag for normalizing outputs.
  • debug (bool.) – flag for printing log messages.
_abc_impl = <_abc_data object>
_get_bounds() → List[T]

It returns list of range tuples, obtained from self.range_X.

Returns:list of range tuples.
Return type:list
_get_random_state(seed: Optional[int])

It returns a random state, defined by seed.

Parameters:seed (NoneType or int.) – None, or a random seed.
Returns:a random state.
Return type:numpy.random.RandomState
Raises:AssertionError
_get_samples_gaussian(num_samples: int, seed: Optional[int] = None) → numpy.ndarray

It returns num_samples examples sampled from Gaussian distribution.

Parameters:
  • num_samples (int.) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

random examples. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

_get_samples_grid(num_grids: int = 50) → numpy.ndarray

It returns grids of self.range_X.

Parameters:num_grids (int., optional) – the number of grids.
Returns:grids of self.range_X. Shape: (num_grids\(^{\text{d}}\), d).
Return type:numpy.ndarray
Raises:AssertionError
_get_samples_halton(num_samples: int, seed: Optional[int] = None) → numpy.ndarray

It returns num_samples examples sampled by Halton algorithm.

Parameters:
  • num_samples (int.) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

examples sampled by Halton algorithm. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

_get_samples_sobol(num_samples: int, seed: Optional[int] = None) → numpy.ndarray

It returns num_samples examples sampled from Sobol’ sequence.

Parameters:
  • num_samples (int.) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

examples sampled from Sobol’ sequence. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

_get_samples_uniform(num_samples: int, seed: Optional[int] = None) → numpy.ndarray

It returns num_samples examples uniformly sampled.

Parameters:
  • num_samples (int.) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

random examples. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

compute_acquisitions()

It is an abstract method.

compute_posteriors()

It is an abstract method.

get_initials(str_initial_method: str, num_initials: int, seed: Optional[int] = None) → numpy.ndarray

It returns num_initials examples, sampled by a sampling method str_initial_method.

Parameters:
  • str_initial_method (str.) – the name of sampling method.
  • num_initials (int.) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

sampled examples. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

get_samples(str_sampling_method: str, fun_objective: Optional[Callable] = None, num_samples: int = 100, seed: Optional[int] = None) → numpy.ndarray

It returns num_samples examples, sampled by a sampling method str_sampling_method.

Parameters:
  • str_sampling_method (str.) – the name of sampling method.
  • fun_objective (NoneType or callable, optional) – None, or objective function.
  • num_samples (int., optional) – the number of samples.
  • seed (NoneType or int., optional) – None, or random seed.
Returns:

sampled examples. Shape: (num_samples, d).

Return type:

numpy.ndarray

Raises:

AssertionError

optimize()

It is an abstract method.