-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from jungtaekkim/0.5.3
0.5.3
- Loading branch information
Showing
21 changed files
with
297 additions
and
143 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,9 +72,10 @@ We test our package in the following versions. | |
* Python 3.7 | ||
* Python 3.8 | ||
* Python 3.9 | ||
* Python 3.10 | ||
|
||
## Contributor | ||
* [Jungtaek Kim](https://jungtaek.github.io) (POSTECH) | ||
* [Jungtaek Kim](https://jungtaek.github.io) | ||
|
||
## Citation | ||
``` | ||
|
@@ -87,7 +88,7 @@ We test our package in the following versions. | |
``` | ||
|
||
## Contact | ||
* Jungtaek Kim: [[email protected]](mailto:[email protected]) | ||
* [Jungtaek Kim](https://jungtaek.github.io) | ||
|
||
## License | ||
[MIT License](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: October 23, 2021 | ||
# last updated: February 3, 2022 | ||
# | ||
"""BayesO is a simple, but essential Bayesian optimization | ||
package, implemented in Python.""" | ||
|
||
|
||
__version__ = '0.5.2' | ||
__version__ = '0.5.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: October 8, 2021 | ||
# last updated: February 4, 2022 | ||
# | ||
"""It defines a class of Bayesian optimization | ||
with Gaussian process regression.""" | ||
|
@@ -453,6 +453,10 @@ def optimize(self, X_train: np.ndarray, Y_train: np.ndarray, | |
) | ||
next_point, next_points = self._optimize(fun_negative_acquisition, | ||
str_sampling_method=str_sampling_method, num_samples=num_samples) | ||
|
||
next_point = utils_bo.check_points_in_bounds(next_point[np.newaxis, ...], np.array(self._get_bounds()))[0] | ||
next_points = utils_bo.check_points_in_bounds(next_points, np.array(self._get_bounds())) | ||
|
||
time_end_acq = time.time() | ||
|
||
acquisitions = fun_negative_acquisition(next_points) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: October 8, 2021 | ||
# last updated: February 4, 2022 | ||
# | ||
"""It defines a class of Bayesian optimization | ||
with Student-:math:`t` process regression.""" | ||
|
@@ -375,6 +375,10 @@ def optimize(self, X_train: np.ndarray, Y_train: np.ndarray, | |
) | ||
next_point, next_points = self._optimize(fun_negative_acquisition, | ||
str_sampling_method=str_sampling_method, num_samples=num_samples) | ||
|
||
next_point = utils_bo.check_points_in_bounds(next_point[np.newaxis, ...], np.array(self._get_bounds()))[0] | ||
next_points = utils_bo.check_points_in_bounds(next_points, np.array(self._get_bounds())) | ||
|
||
time_end_acq = time.time() | ||
|
||
acquisitions = fun_negative_acquisition(next_points) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: October 8, 2021 | ||
# last updated: February 4, 2022 | ||
# | ||
"""It defines a class of Bayesian optimization | ||
with tree-based surrogate models.""" | ||
|
@@ -253,6 +253,8 @@ def optimize(self, X_train: np.ndarray, Y_train: np.ndarray, | |
num_samples=num_samples | ||
) | ||
|
||
next_points = utils_bo.check_points_in_bounds(next_points, np.array(self._get_bounds())) | ||
|
||
fun_negative_acquisition = lambda X_test: -1.0 * self.compute_acquisitions( | ||
X_test, X_train, Y_train, trees | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 4, 2022 | ||
# | ||
"""It is utilities for Bayesian optimization.""" | ||
|
||
|
@@ -286,3 +286,33 @@ def check_hyps_convergence(list_hyps: constants.TYPING_LIST[dict], hyps: dict, | |
if np.linalg.norm(hyps_converted - target_hyps_converted, ord=2) < threshold: | ||
converged = True | ||
return converged | ||
|
||
@utils_common.validate_types | ||
def check_points_in_bounds(points: np.ndarray, bounds: np.ndarray | ||
) -> np.ndarray: | ||
""" | ||
It checks whether every instance of `points` is located in `bounds`. | ||
:param points: points to check. Shape: (n, d). | ||
:type points: numpy.ndarray | ||
:param bounds: upper and lower bounds. Shape: (d, 2). | ||
:type bounds: numpy.ndarray | ||
:returns: points in `bounds`. Shape: (n, d). | ||
:rtype: numpy.ndarray | ||
:raises: AssertionError | ||
""" | ||
|
||
assert isinstance(points, np.ndarray) | ||
assert isinstance(bounds, np.ndarray) | ||
assert len(points.shape) == 2 | ||
assert len(bounds.shape) == 2 | ||
assert points.shape[1] == bounds.shape[0] | ||
assert bounds.shape[1] == 2 | ||
|
||
assert np.all(points >= bounds[:, 0]) | ||
assert np.all(points <= bounds[:, 1]) | ||
|
||
return points |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.