Skip to content

Commit

Permalink
Update docstrings for bo_w_trees
Browse files Browse the repository at this point in the history
  • Loading branch information
jungtaekkim committed Oct 11, 2021
1 parent 5821784 commit 873929e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
4 changes: 4 additions & 0 deletions bayeso/bo/bo_w_gp.py
Expand Up @@ -208,6 +208,8 @@ def compute_posteriors(self,
over `X_test`. Shape: ((l, ), (l, )).
:rtype: (numpy.ndarray, numpy.ndarray)
:raises: AssertionError
"""

assert isinstance(X_train, np.ndarray)
Expand Down Expand Up @@ -266,6 +268,8 @@ def compute_acquisitions(self, X: np.ndarray,
:returns: acquisition function values over `X`. Shape: (l, ).
:rtype: numpy.ndarray
:raises: AssertionError
"""

assert isinstance(X, np.ndarray)
Expand Down
4 changes: 4 additions & 0 deletions bayeso/bo/bo_w_tp.py
Expand Up @@ -199,6 +199,8 @@ def compute_posteriors(self,
:returns: posterior mean and standard deviation over `X_test`. Shape: ((l, ), (l, )).
:rtype: (numpy.ndarray, numpy.ndarray)
:raises: AssertionError
"""

assert isinstance(X_train, np.ndarray)
Expand Down Expand Up @@ -257,6 +259,8 @@ def compute_acquisitions(self, X: np.ndarray,
:returns: acquisition function values over `X`. Shape: (l, ).
:rtype: numpy.ndarray
:raises: AssertionError
"""

assert isinstance(X, np.ndarray)
Expand Down
47 changes: 40 additions & 7 deletions bayeso/bo/bo_w_trees.py
Expand Up @@ -67,6 +67,37 @@ def get_trees(self, X_train, Y_train,
depth_max=5,
size_min_leaf=1,
):
"""
It returns a list of trees.
:param X_train: inputs. Shape: (n, d).
:type X_train: numpy.ndarray
:param Y_train: outputs. Shape: (n, 1).
:type Y_train: numpy.ndarray
:param num_trees: the number of trees.
:type num_trees: int., optional
:param depth_max: maximum depth.
:type depth_max: int., optional
:param size_min_leaf: minimum size of leaves.
:type size_min_leaf: int., optional
:returns: list of trees.
:rtype: list
:raises: AssertionError
"""

assert isinstance(X_train, np.ndarray)
assert isinstance(Y_train, np.ndarray)
assert isinstance(num_trees, int)
assert isinstance(depth_max, int)
assert isinstance(size_min_leaf, int)
assert len(X_train.shape) == 2
assert len(Y_train.shape) == 2
assert X_train.shape[0] == Y_train.shape[0]
assert Y_train.shape[1] == 1

num_features = int(np.sqrt(self.num_dim))

if self.str_surrogate == 'rf':
Expand All @@ -85,19 +116,17 @@ def compute_posteriors(self,
"""
It returns posterior mean and standard deviation functions over `X`.
:param X: inputs. Shape: (l, d).
:param X: inputs to test. Shape: (l, d).
:type X: numpy.ndarray
:param cov_X_X: kernel matrix over `X_train`. Shape: (n, n).
:type cov_X_X: numpy.ndarray
:param inv_cov_X_X: kernel matrix inverse over `X_train`. Shape: (n, n).
:type inv_cov_X_X: numpy.ndarray
:param hyps: dictionary of hyperparameters for Gaussian process.
:type hyps: dict.
:param trees: list of trees.
:type trees: list
:returns: posterior mean and standard deviation functions
over `X`. Shape: ((l, ), (l, )).
:rtype: (numpy.ndarray, numpy.ndarray)
:raises: AssertionError
"""

assert isinstance(X, np.ndarray)
Expand Down Expand Up @@ -126,10 +155,14 @@ def compute_acquisitions(self, X: np.ndarray,
:type X_train: numpy.ndarray
:param Y_train: outputs. Shape: (n, 1).
:type Y_train: numpy.ndarray
:param trees: list of trees.
:type trees: list
:returns: acquisition function values over `X`. Shape: (l, ).
:rtype: numpy.ndarray
:raises: AssertionError
"""

assert isinstance(X, np.ndarray)
Expand Down

0 comments on commit 873929e

Please sign in to comment.