bayeso.bo.bo_w_trees¶
It defines a class of Bayesian optimization with tree-based surrogate models.
-
class
bayeso.bo.bo_w_trees.
BOwTrees
(range_X: numpy.ndarray, str_surrogate: str = 'rf', str_acq: str = 'ei', normalize_Y: bool = True, str_optimizer_method_bo: str = 'random_search', debug: bool = False)¶ Bases:
bayeso.bo.base_bo.BaseBO
It is a Bayesian optimization class with tree-based surrogate models.
Parameters: - range_X (numpy.ndarray) – a search space. Shape: (d, 2).
- str_surrogate (str., optional) – the name of surrogate model.
- str_acq (str., optional) – the name of acquisition function.
- normalize_Y (bool., optional) – flag for normalizing outputs.
- 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>¶
-
compute_acquisitions
(X: numpy.ndarray, X_train: numpy.ndarray, Y_train: numpy.ndarray, trees: List[T]) → numpy.ndarray¶ It computes acquisition function values over ‘X’, where X_train and Y_train are given.
Parameters: - X (numpy.ndarray) – inputs. Shape: (l, d).
- X_train (numpy.ndarray) – inputs. Shape: (n, d).
- Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
- trees (list) – list of trees.
Returns: acquisition function values over X. Shape: (l, ).
Return type: numpy.ndarray
Raises: AssertionError
-
compute_posteriors
(X: numpy.ndarray, trees: List[T]) → numpy.ndarray¶ It returns posterior mean and standard deviation functions over X.
Parameters: - X (numpy.ndarray) – inputs to test. Shape: (l, d).
- trees (list) – list of trees.
Returns: posterior mean and standard deviation functions over X. Shape: ((l, ), (l, )).
Return type: (numpy.ndarray, numpy.ndarray)
Raises: AssertionError
-
get_trees
(X_train, Y_train, num_trees=100, depth_max=5, size_min_leaf=1)¶ It returns a list of trees.
Parameters: - X_train (numpy.ndarray) – inputs. Shape: (n, d).
- Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
- num_trees (int., optional) – the number of trees.
- depth_max (int., optional) – maximum depth.
- size_min_leaf (int., optional) – minimum size of leaves.
Returns: list of trees.
Return type: list
Raises: AssertionError
-
optimize
(X_train: numpy.ndarray, Y_train: numpy.ndarray, str_sampling_method: str = 'uniform', num_samples: int = 5000) → 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).
- 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