bayeso.bo.base_bo
It defines an abstract class of Bayesian optimization.
- class bayeso.bo.base_bo.BaseBO(range_X: ndarray, str_surrogate: str, str_acq: str, str_optimizer_method_bo: str, normalize_Y: bool, str_exp: str, debug: bool)
Bases:
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.
str_exp (str.) – the name of experiment.
debug (bool.) – flag for printing log messages.
- _abc_impl = <_abc._abc_data object>
- _get_bounds() List
It returns list of range tuples, obtained from self.range_X.
- Returns:
list of range tuples.
- Return type:
list
- _get_random_state(seed: int | None)
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: int | None = None) 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) 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: int | None = None) 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: int | None = None) 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: int | None = None) 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
- abstract compute_acquisitions()
It is an abstract method.
- abstract compute_posteriors()
It is an abstract method.
- get_initials(str_initial_method: str, num_initials: int, seed: int | None = None) 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, num_samples: int = 128, seed: int | None = None) ndarray
It returns num_samples examples, sampled by a sampling method str_sampling_method.
- Parameters:
str_sampling_method (str.) – the name of sampling method.
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
- abstract optimize()
It is an abstract method.