From 201c6b24d4a8e93d442a46ad4a2980adfc5df1ea Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Sat, 5 Aug 2023 16:10:14 +0200 Subject: [PATCH 01/13] Replace custom colour implementation, add docs for `logger.py`, `util.py` (#435) * Replace custom colour implementation, add docs for `logger.py`, `util.py` * minor typo/syntax fixes * User `or` to separate different possible types --- bayes_opt/logger.py | 191 +++++++++++++++--- bayes_opt/target_space.py | 6 +- bayes_opt/util.py | 342 ++++++++++++++++++++------------- docsrc/code_docs.rst | 2 +- examples/async_optimization.py | 13 +- examples/sklearn_example.py | 6 +- tests/test_util.py | 24 +-- 7 files changed, 388 insertions(+), 196 deletions(-) diff --git a/bayes_opt/logger.py b/bayes_opt/logger.py index edcfa836c..273087e9f 100644 --- a/bayes_opt/logger.py +++ b/bayes_opt/logger.py @@ -1,17 +1,48 @@ +"""Contains classes and functions for logging.""" from __future__ import print_function import os import json -import warnings -from pathlib import Path from .observer import _Tracker from .event import Events -from .util import Colours +from colorama import Fore, just_fix_windows_console + +just_fix_windows_console() def _get_default_logger(verbose, is_constrained): + """ + Return the default logger. + + Parameters + ---------- + verbose : int + Verbosity level of the logger. + + is_constrained : bool + Whether the underlying optimizer uses constraints (this requires + an additional column in the output). + + Returns + ------- + ScreenLogger + The default logger. + + """ return ScreenLogger(verbose=verbose, is_constrained=is_constrained) class ScreenLogger(_Tracker): + """Logger that outputs text, e.g. to log to a terminal. + + Parameters + ---------- + verbose : int + Verbosity level of the logger. + + is_constrained : bool + Whether the logger is associated with a constrained optimization + instance. + """ + _default_cell_size = 9 _default_precision = 4 @@ -19,64 +50,106 @@ def __init__(self, verbose=2, is_constrained=False): self._verbose = verbose self._is_constrained = is_constrained self._header_length = None - super(ScreenLogger, self).__init__() + super().__init__() @property def verbose(self): + """Return the verbosity level.""" return self._verbose @verbose.setter def verbose(self, v): + """Set the verbosity level. + + Parameters + ---------- + v : int + New verbosity level of the logger. + """ self._verbose = v @property def is_constrained(self): + """Return whether the logger is constrained.""" return self._is_constrained def _format_number(self, x): + """Format a number. + + Parameters + ---------- + x : number + + + Returns + ------- + A stringified, formatted version of `x`. + """ if isinstance(x, int): - s = "{x:<{s}}".format( - x=x, - s=self._default_cell_size, - ) + s = f"{x:<{self._default_cell_size}}" else: - s = "{x:<{s}.{p}}".format( - x=x, - s=self._default_cell_size, - p=self._default_precision, - ) + s = f"{x:<{self._default_cell_size}.{self._default_precision}}" if len(s) > self._default_cell_size: if "." in s: return s[:self._default_cell_size] - else: - return s[:self._default_cell_size - 3] + "..." + return s[:self._default_cell_size - 3] + "..." return s def _format_bool(self, x): + """Format a boolean. + + Parameters + ---------- + x : boolean + + + Returns + ------- + A stringified, formatted version of `x`. + """ if 5 > self._default_cell_size: - if x == True: + if x: x_ = 'T' - elif x == False: + else: x_ = 'F' else: x_ = str(x) - s = "{x:<{s}}".format( - x=x_, - s=self._default_cell_size, - ) + s = f"{x_:<{self._default_cell_size}}" return s def _format_key(self, key): - s = "{key:^{s}}".format( - key=key, - s=self._default_cell_size - ) + """Format a key. + + Parameters + ---------- + key : string + + + Returns + ------- + A stringified, formatted version of `x`. + """ + s = f"{key:^{self._default_cell_size}}" if len(s) > self._default_cell_size: return s[:self._default_cell_size - 3] + "..." return s - def _step(self, instance, colour=Colours.black): + def _step(self, instance, colour=Fore.BLACK): + """Log a step. + + Parameters + ---------- + instance : bayesian_optimization.BayesianOptimization + The instance associated with the event. + + colour : + (Default value = Fore.BLACK) + + Returns + ------- + A stringified, formatted version of the most recent optimization step. + """ res = instance.res[-1] cells = [] @@ -89,9 +162,20 @@ def _step(self, instance, colour=Colours.black): for key in instance.space.keys: cells.append(self._format_number(res["params"][key])) - return "| " + " | ".join(map(colour, cells)) + " |" + return "| " + " | ".join([colour + cells[i] for i in range(len(cells))]) + " |" def _header(self, instance): + """Print the header of the log. + + Parameters + ---------- + instance : bayesian_optimization.BayesianOptimization + The instance associated with the header. + + Returns + ------- + A stringified, formatted version of the most header. + """ cells = [] cells.append(self._format_key("iter")) cells.append(self._format_key("target")) @@ -107,6 +191,17 @@ def _header(self, instance): return line + "\n" + ("-" * self._header_length) def _is_new_max(self, instance): + """Check if the step to log produced a new maximum. + + Parameters + ---------- + instance : bayesian_optimization.BayesianOptimization + The instance associated with the step. + + Returns + ------- + boolean + """ if instance.max is None: # During constrained optimization, there might not be a maximum # value since the optimizer might've not encountered any points @@ -117,6 +212,17 @@ def _is_new_max(self, instance): return instance.max["target"] > self._previous_max def update(self, event, instance): + """Handle incoming events. + + Parameters + ---------- + event : str + One of the values associated with `Events.OPTIMIZATION_START`, + `Events.OPTIMIZATION_STEP` or `Events.OPTIMIZATION_END`. + + instance : bayesian_optimization.BayesianOptimization + The instance associated with the step. + """ if event == Events.OPTIMIZATION_START: line = self._header(instance) + "\n" elif event == Events.OPTIMIZATION_STEP: @@ -124,7 +230,7 @@ def update(self, event, instance): if self._verbose == 1 and not is_new_max: line = "" else: - colour = Colours.purple if is_new_max else Colours.black + colour = Fore.MAGENTA if is_new_max else Fore.BLACK line = self._step(instance, colour=colour) + "\n" elif event == Events.OPTIMIZATION_END: line = "=" * self._header_length + "\n" @@ -135,18 +241,43 @@ def update(self, event, instance): class JSONLogger(_Tracker): - def __init__(self, path, reset=True): + """ + Logger that outputs steps in JSON format. + The resulting file can be used to restart the optimization from an earlier state. + """ + def __init__(self, path, reset=True): + """ + Initialize the logger. + + Parameters + ---------- + path : str or bytes or os.PathLike + + """ self._path = path if reset: try: os.remove(self._path) except OSError: pass - super(JSONLogger, self).__init__() + super().__init__() def update(self, event, instance): + """ + Handle incoming events. + + Parameters + ---------- + event : str + One of the values associated with `Events.OPTIMIZATION_START`, + `Events.OPTIMIZATION_STEP` or `Events.OPTIMIZATION_END`. + + instance : bayesian_optimization.BayesianOptimization + The instance associated with the step. + + """ if event == Events.OPTIMIZATION_STEP: data = dict(instance.res[-1]) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index e90cfbcf0..dea99f976 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -1,6 +1,6 @@ import numpy as np from .util import ensure_rng, NotUniqueError -from .util import Colours +from colorama import Fore def _hashable(x): @@ -188,8 +188,8 @@ def register(self, params, target, constraint_value=None): if x in self: if self._allow_duplicate_points: self.n_duplicate_points = self.n_duplicate_points + 1 - print(f'{Colours.RED}Data point {x} is not unique. {self.n_duplicate_points} duplicates registered.' - f' Continuing ...{Colours.END}') + print(Fore.RED + f'Data point {x} is not unique. {self.n_duplicate_points} duplicates registered.' + f' Continuing ...') else: raise NotUniqueError(f'Data point {x} is not unique. You can set "allow_duplicate_points=True" to ' f'avoid this error') diff --git a/bayes_opt/util.py b/bayes_opt/util.py index 2ac87254b..d8a4f9077 100644 --- a/bayes_opt/util.py +++ b/bayes_opt/util.py @@ -1,55 +1,69 @@ +"""Contains utility functions.""" +import json import warnings import numpy as np from scipy.stats import norm from scipy.optimize import minimize -from colorama import just_fix_windows_console -import json def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10): - """ - A function to find the maximum of the acquisition function - + """Find the maximum of the acquisition function. + It uses a combination of random sampling (cheap) and the 'L-BFGS-B' optimization method. First by sampling `n_warmup` (1e5) points at random, - and then running L-BFGS-B from `n_iter` (250) random starting points. + and then running L-BFGS-B from `n_iter` (10) random starting points. Parameters ---------- - :param ac: - The acquisition function object that return its point-wise value. - - :param gp: - A gaussian process fitted to the relevant data. - - :param y_max: - The current maximum known value of the target function. - - :param bounds: - The variables bounds to limit the search of the acq max. - - :param random_state: - instance of np.RandomState random number generator - - :param constraint: - A ConstraintModel. - - :param n_warmup: - number of times to randomly sample the acquisition function - - :param n_iter: - number of times to run scipy.minimize + ac : callable + Acquisition function to use. Should accept an array of parameters `x`, + an from sklearn.gaussian_process.GaussianProcessRegressor `gp` and the + best current value `y_max` as parameters. + + gp : sklearn.gaussian_process.GaussianProcessRegressor + A gaussian process regressor modelling the target function based on + previous observations. + + y_max : number + Highest found value of the target function. + + bounds : np.ndarray + Bounds of the search space. For `N` parameters this has shape + `(N, 2)` with `[i, 0]` the lower bound of parameter `i` and + `[i, 1]` the upper bound. + + random_state : np.random.RandomState + A random state to sample from. + + constraint : ConstraintModel or None, default=None + + n_warmup : int, default=10000 + Number of points to sample from the acquisition function as seeds + before looking for a minimum. + + n_iter : int, default=10 + Points to run L-BFGS-B optimization from. Returns ------- - :return: x_max, The arg max of the acquisition function. - """ + Parameters maximizing the acquisition function. + """ # We need to adjust the acquisition function to deal with constraints when there is some if constraint is not None: def adjusted_ac(x): - """Acquisition function adjusted to fulfill the constraint when necessary""" + """Acquisition function adjusted to fulfill the constraint when necessary. + Parameters + ---------- + x : np.ndarray + Parameter at which to sample. + + + Returns + ------- + The value of the acquisition function adjusted for constraints. + """ # Transforms the problem in a minimization problem, this is necessary # because the solver we are using later on is a minimizer values = -ac(x.reshape(-1, bounds.shape[0]), gp=gp, y_max=y_max) @@ -110,33 +124,33 @@ def adjusted_ac(x): return np.clip(x_max, bounds[:, 0], bounds[:, 1]) -class UtilityFunction(object): - """ - An object to compute the acquisition functions. - +class UtilityFunction(): + """An object to compute the acquisition functions. + + Parameters + ---------- kind: {'ucb', 'ei', 'poi'} * 'ucb' stands for the Upper Confidence Bounds method * 'ei' is the Expected Improvement method * 'poi' is the Probability Of Improvement criterion. - + kappa: float, optional(default=2.576) Parameter to indicate how closed are the next parameters sampled. Higher value = favors spaces that are least explored. Lower value = favors spaces where the regression function is the highest. - + kappa_decay: float, optional(default=1) `kappa` is multiplied by this factor every iteration. - + kappa_decay_delay: int, optional(default=0) Number of iterations that must have passed before applying the decay to `kappa`. - + xi: float, optional(default=0.0) """ def __init__(self, kind='ucb', kappa=2.576, xi=0, kappa_decay=1, kappa_decay_delay=0): - self.kappa = kappa self._kappa_decay = kappa_decay self._kappa_decay_delay = kappa_decay_delay @@ -147,28 +161,81 @@ def __init__(self, kind='ucb', kappa=2.576, xi=0, kappa_decay=1, kappa_decay_del if kind not in ['ucb', 'ei', 'poi']: err = "The utility function " \ - "{} has not been implemented, " \ - "please choose one of ucb, ei, or poi.".format(kind) + f"{kind} has not been implemented, " \ + "please choose one of ucb, ei, or poi." raise NotImplementedError(err) - else: - self.kind = kind + self.kind = kind def update_params(self): + """Update internal parameters.""" self._iters_counter += 1 if self._kappa_decay < 1 and self._iters_counter > self._kappa_decay_delay: self.kappa *= self._kappa_decay def utility(self, x, gp, y_max): + """Calculate acquisition function. + + Parameters + ---------- + x : np.ndarray + Parameters to evaluate the function at. + + gp : sklearn.gaussian_process.GaussianProcessRegressor + A gaussian process regressor modelling the target function based on + previous observations. + + y_max : number + Highest found value of the target function. + + + Returns + ------- + Values of the acquisition function + """ if self.kind == 'ucb': - return self._ucb(x, gp, self.kappa) + return self.ucb(x, gp, self.kappa) if self.kind == 'ei': - return self._ei(x, gp, y_max, self.xi) + return self.ei(x, gp, y_max, self.xi) if self.kind == 'poi': - return self._poi(x, gp, y_max, self.xi) + return self.poi(x, gp, y_max, self.xi) + raise ValueError(f"{self.kind} is not a valid acquisition function.") @staticmethod - def _ucb(x, gp, kappa): + def ucb(x, gp, kappa): + r"""Calculate Upper Confidence Bound acquisition function. + + Similar to Probability of Improvement (`UtilityFunction.poi`), but also considers the + magnitude of improvement. + Calculated as + + .. math:: + \text{UCB}(x) = \mu(x) + \kappa \sigma(x) + + where :math:`\Phi` is the CDF and :math:`\phi` the PDF of the normal + distribution. + + Parameters + ---------- + x : np.ndarray + Parameters to evaluate the function at. + + gp : sklearn.gaussian_process.GaussianProcessRegressor + A gaussian process regressor modelling the target function based on + previous observations. + + y_max : number + Highest found value of the target function. + + kappa : float, positive + Governs the exploration/exploitation tradeoff. Lower prefers + exploitation, higher prefers exploration. + + + Returns + ------- + Values of the acquisition function + """ with warnings.catch_warnings(): warnings.simplefilter("ignore") mean, std = gp.predict(x, return_std=True) @@ -176,17 +243,82 @@ def _ucb(x, gp, kappa): return mean + kappa * std @staticmethod - def _ei(x, gp, y_max, xi): + def ei(x, gp, y_max, xi): + r"""Calculate Expected Improvement acqusition function. + + Similar to Probability of Improvement (`UtilityFunction.poi`), but also considers the + magnitude of improvement. + Calculated as + + .. math:: + \text{EI}(x) = (\mu(x)-y_{\text{max}} - \xi) \Phi\left( + \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right) + + \sigma(x) \phi\left( + \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right) + + where :math:`\Phi` is the CDF and :math:`\phi` the PDF of the normal + distribution. + + Parameters + ---------- + x : np.ndarray + Parameters to evaluate the function at. + + gp : sklearn.gaussian_process.GaussianProcessRegressor + A gaussian process regressor modelling the target function based on + previous observations. + + y_max : number + Highest found value of the target function. + + xi : float, positive + Governs the exploration/exploitation tradeoff. Lower prefers + exploitation, higher prefers exploration. + + + Returns + ------- + Values of the acquisition function + """ with warnings.catch_warnings(): warnings.simplefilter("ignore") mean, std = gp.predict(x, return_std=True) - a = (mean - y_max - xi) + a = mean - y_max - xi z = a / std return a * norm.cdf(z) + std * norm.pdf(z) @staticmethod - def _poi(x, gp, y_max, xi): + def poi(x, gp, y_max, xi): + r"""Calculate Probability of Improvement acqusition function. + + Calculated as + + .. math:: \text{POI}(x) = \Phi\left( \frac{\mu(x)-y_{\text{max}} - \xi }{\sigma(x)} \right) + + where :math:`\Phi` is the CDF of the normal distribution. + + Parameters + ---------- + x : np.ndarray + Parameters to evaluate the function at. + gp : sklearn.gaussian_process.GaussianProcessRegressor + A gaussian process regressor modelling the target function based on + previous observations. + + y_max : number + Highest found value of the target function. + + xi : float, positive + Governs the exploration/exploitation tradeoff. Lower prefers + exploitation, higher prefers exploration. + + + Returns + ------- + Values of the acquisition function + + """ with warnings.catch_warnings(): warnings.simplefilter("ignore") mean, std = gp.predict(x, return_std=True) @@ -197,15 +329,24 @@ def _poi(x, gp, y_max, xi): class NotUniqueError(Exception): """A point is non-unique.""" - pass def load_logs(optimizer, logs): """Load previous ... - """ + Parameters + ---------- + optimizer : BayesianOptimizer + Optimizer the register the previous observations with. + logs : str or bytes or os.PathLike + File to load the logs from. + Returns + ------- + The optimizer with the state loaded. + + """ if isinstance(logs, str): logs = [logs] @@ -222,7 +363,10 @@ def load_logs(optimizer, logs): optimizer.register( params=iteration["params"], target=iteration["target"], - constraint_value=iteration["constraint"] if optimizer.is_constrained else None + constraint_value=( + iteration["constraint"] + if optimizer.is_constrained else None + ) ) except NotUniqueError: continue @@ -231,10 +375,19 @@ def load_logs(optimizer, logs): def ensure_rng(random_state=None): - """ - Creates a random number generator based on an optional seed. This can be - an integer or another random state for a seeded rng, or None for an - unseeded rng. + """Create a random number generator based on an optional seed. + + Parameters + ---------- + random_state : np.random.RandomState or int or None, default=None + Random state to use. if `None`, will create an unseeded random state. + If `int`, creates a state using the argument as seed. If a + `np.random.RandomState` simply returns the argument. + + Returns + ------- + np.random.RandomState + """ if random_state is None: random_state = np.random.RandomState() @@ -244,74 +397,3 @@ def ensure_rng(random_state=None): assert isinstance(random_state, np.random.RandomState) return random_state - -class Colours: - """Print in nice colours.""" - - BLUE = '\033[94m' - BOLD = '\033[1m' - CYAN = '\033[96m' - DARKCYAN = '\033[36m' - END = '\033[0m' - GREEN = '\033[92m' - PURPLE = '\033[95m' - RED = '\033[91m' - UNDERLINE = '\033[4m' - YELLOW = '\033[93m' - - @classmethod - def _wrap_colour(cls, s, colour): - return colour + s + cls.END - - @classmethod - def black(cls, s): - """Wrap text in black.""" - return cls._wrap_colour(s, cls.END) - - @classmethod - def blue(cls, s): - """Wrap text in blue.""" - return cls._wrap_colour(s, cls.BLUE) - - @classmethod - def bold(cls, s): - """Wrap text in bold.""" - return cls._wrap_colour(s, cls.BOLD) - - @classmethod - def cyan(cls, s): - """Wrap text in cyan.""" - return cls._wrap_colour(s, cls.CYAN) - - @classmethod - def darkcyan(cls, s): - """Wrap text in darkcyan.""" - return cls._wrap_colour(s, cls.DARKCYAN) - - @classmethod - def green(cls, s): - """Wrap text in green.""" - return cls._wrap_colour(s, cls.GREEN) - - @classmethod - def purple(cls, s): - """Wrap text in purple.""" - return cls._wrap_colour(s, cls.PURPLE) - - @classmethod - def red(cls, s): - """Wrap text in red.""" - return cls._wrap_colour(s, cls.RED) - - @classmethod - def underline(cls, s): - """Wrap text in underline.""" - return cls._wrap_colour(s, cls.UNDERLINE) - - @classmethod - def yellow(cls, s): - """Wrap text in yellow.""" - return cls._wrap_colour(s, cls.YELLOW) - - -just_fix_windows_console() diff --git a/docsrc/code_docs.rst b/docsrc/code_docs.rst index ebd5a076b..289a1f8b8 100644 --- a/docsrc/code_docs.rst +++ b/docsrc/code_docs.rst @@ -1,7 +1,7 @@ Code Documentation ================== -This page shows the documentation generated by sphinx automatically scanning our source code +This page shows the documentation generated by sphinx automatically scanning the source code. Bayesian Optimization --------------------- diff --git a/examples/async_optimization.py b/examples/async_optimization.py index 3eae4e8aa..3f983cfea 100644 --- a/examples/async_optimization.py +++ b/examples/async_optimization.py @@ -2,10 +2,11 @@ import random from bayes_opt import BayesianOptimization -from bayes_opt.util import UtilityFunction, Colours +from bayes_opt.util import UtilityFunction import asyncio import threading +from colorama import Fore try: import json @@ -96,19 +97,19 @@ def run_optimizer(): status += name + " got {} as target.\n".format(target) status += name + " will to register next: {}.\n".format(register_data) - print(colour(status), end="\n") + print(colour + status, end="\n") global results results.append((name, max_target)) - print(colour(name + " is done!"), end="\n\n") + print(colour + name + " is done!", end="\n\n") if __name__ == "__main__": ioloop = tornado.ioloop.IOLoop.instance() optimizers_config = [ - {"name": "optimizer 1", "colour": Colours.red}, - {"name": "optimizer 2", "colour": Colours.green}, - {"name": "optimizer 3", "colour": Colours.blue}, + {"name": "optimizer 1", "colour": Fore.RED}, + {"name": "optimizer 2", "colour": Fore.GREEN}, + {"name": "optimizer 3", "colour": Fore.BLUE}, ] app_thread = threading.Thread(target=run_optimization_app) diff --git a/examples/sklearn_example.py b/examples/sklearn_example.py index 27ef7e8b4..14be8dee6 100644 --- a/examples/sklearn_example.py +++ b/examples/sklearn_example.py @@ -4,7 +4,7 @@ from sklearn.svm import SVC from bayes_opt import BayesianOptimization -from bayes_opt.util import Colours +from colorama import Fore def get_data(): """Synthetic binary classification dataset.""" @@ -114,8 +114,8 @@ def rfc_crossval(n_estimators, min_samples_split, max_features): if __name__ == "__main__": data, targets = get_data() - print(Colours.yellow("--- Optimizing SVM ---")) + print(Fore.YELLOW + "--- Optimizing SVM ---") optimize_svc(data, targets) - print(Colours.green("--- Optimizing Random Forest ---")) + print(Fore.GREEN("--- Optimizing Random Forest ---")) optimize_rfc(data, targets) diff --git a/tests/test_util.py b/tests/test_util.py index 16ec28fd6..b3a73668a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -2,7 +2,7 @@ import numpy as np from bayes_opt import BayesianOptimization -from bayes_opt.util import UtilityFunction, Colours +from bayes_opt.util import UtilityFunction from bayes_opt.util import acq_max, load_logs, ensure_rng from sklearn.gaussian_process.kernels import Matern @@ -174,28 +174,6 @@ def c(x, y): assert len(optimizer.space) == 7 -def test_colours(): - colour_wrappers = [ - (Colours.END, Colours.black), - (Colours.BLUE, Colours.blue), - (Colours.BOLD, Colours.bold), - (Colours.CYAN, Colours.cyan), - (Colours.DARKCYAN, Colours.darkcyan), - (Colours.GREEN, Colours.green), - (Colours.PURPLE, Colours.purple), - (Colours.RED, Colours.red), - (Colours.UNDERLINE, Colours.underline), - (Colours.YELLOW, Colours.yellow), - ] - - for colour, wrapper in colour_wrappers: - text1 = Colours._wrap_colour("test", colour) - text2 = wrapper("test") - - assert text1.split("test") == [colour, Colours.END] - assert text2.split("test") == [colour, Colours.END] - - if __name__ == '__main__': r""" CommandLine: From b9f16f276eab29a820b2330485fe26aa10f598fc Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Sun, 13 Aug 2023 16:35:57 +0200 Subject: [PATCH 02/13] Update docs & linting for `constraints.py`, `target_space.py` (#440) * Run tests on any PR * Update docs, linting * Update bayes_opt/constraint.py Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> * Rename mislabelled parameters --------- Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> --- .github/workflows/run_tests.yml | 1 - bayes_opt/constraint.py | 174 ++++++++++++++------ bayes_opt/target_space.py | 282 ++++++++++++++++++++++---------- 3 files changed, 314 insertions(+), 143 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 3a809789e..0551a364e 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -7,7 +7,6 @@ on: push: branches: [ "master" ] pull_request: - branches: [ "master" ] permissions: contents: read diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index a31142310..5ea333525 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -1,3 +1,4 @@ +"""Constraint handling.""" import numpy as np from sklearn.gaussian_process.kernels import Matern from sklearn.gaussian_process import GaussianProcessRegressor @@ -5,42 +6,35 @@ class ConstraintModel(): - """ + """Model constraints using GPRs. + This class takes the function to optimize as well as the parameters bounds in order to find which values for the parameters yield the maximum value using bayesian optimization. Parameters ---------- - fun: function - Constraint function. If multiple constraints are handled, this should - return a numpy.ndarray of appropriate size. - - lb: numeric or numpy.ndarray - Upper limit(s) for the constraints. The return value of `fun` should - have exactly this shape. - - ub: numeric or numpy.ndarray - Upper limit(s) for the constraints. The return value of `fun` should - have exactly this shape. - - random_state: int or numpy.random.RandomState, optional(default=None) - If the value is an integer, it is used as the seed for creating a - numpy.random.RandomState. Otherwise the random state provided is used. - When set to None, an unseeded random state is generated. - - Note - ---- - In case of multiple constraints, this model assumes conditional - independence. This means that for each constraint, the probability of - fulfillment is the cdf of a univariate Gaussian. The overall probability - is a simply the product of the individual probabilities. + fun : None or Callable -> float or np.ndarray + The constraint function. Should be float-valued or array-valued (if + multiple constraints are present). Needs to take the same parameters + as the optimization target with the same argument names. + + lb : float or np.ndarray + The lower bound on the constraints. Should have the same + dimensionality as the return value of the constraint function. + + ub : float or np.ndarray + The upper bound on the constraints. Should have the same + dimensionality as the return value of the constraint function. + + random_state : np.random.RandomState or int or None, default=None + Random state to use. """ def __init__(self, fun, lb, ub, random_state=None): self.fun = fun - self._lb = np.atleast_1d(lb) + self._lb = np.atleast_1d(lb) self._ub = np.atleast_1d(ub) if np.any(self._lb >= self._ub): @@ -58,19 +52,36 @@ def __init__(self, fun, lb, ub, random_state=None): @property def lb(self): + """Return lower bounds.""" return self._lb @property def ub(self): + """Return upper bounds.""" return self._ub - + @property def model(self): + """Return GP regressors of the constraint function.""" return self._model def eval(self, **kwargs): - """ - Evaluates the constraint function. + """Evaluate the constraint function. + + Parameters + ---------- + **kwargs : + Function arguments to evaluate the constraint function on. + + + Returns + ------- + Value of the constraint function. + + Raises + ------ + TypeError + If the kwargs keys don't match the function argument names. """ try: return self.fun(**kwargs) @@ -85,8 +96,19 @@ def eval(self, **kwargs): raise def fit(self, X, Y): - """ - Fits internal GaussianProcessRegressor's to the data. + """Fit internal GPRs to the data. + + Parameters + ---------- + X : + Parameters of the constraint function. + Y : + Values of the constraint function. + + + Returns + ------- + None """ if len(self._model) == 1: self._model[0].fit(X, Y) @@ -95,13 +117,39 @@ def fit(self, X, Y): gp.fit(X, Y[:, i]) def predict(self, X): - """ - Returns the probability that the constraint is fulfilled at `X` based - on the internal Gaussian Process Regressors. + r"""Calculate the probability that the constraint is fulfilled at `X`. + + Note that this does not try to approximate the values of the + constraint function (for this, see `ConstraintModel.approx()`.), but + probability that the constraint function is fulfilled. That is, this + function calculates + + .. math:: + p = \text{Pr}\left\{c^{\text{low}} \leq \tilde{c}(x) \leq + c^{\text{up}} \right\} = \int_{c^{\text{low}}}^{c^{\text{up}}} + \mathcal{N}(c, \mu(x), \sigma^2(x)) \, dc. + + with :math:`\mu(x)`, :math:`\sigma^2(x)` the mean and variance at + :math:`x` as given by the GP and :math:`c^{\text{low}}`, + :math:`c^{\text{up}}` the lower and upper bounds of the constraint + respectively. + + In case of multiple constraints, we assume conditional independence. + This means we calculate the probability of constraint fulfilment + individually, with the joint probability given as their product. + + Parameters + ---------- + X : np.ndarray of shape (n_samples, n_features) + Parameters for which to predict the probability of constraint + fulfilment. + + + Returns + ------- + np.ndarray of shape (n_samples,) + Probability of constraint fulfilment. - Note that this does not try to approximate the values of the constraint - function, but probability that the constraint function is fulfilled. - For the former, see `ConstraintModel.approx()`. """ X_shape = X.shape X = X.reshape((-1, self._model[0].n_features_in_)) @@ -114,33 +162,53 @@ def predict(self, X): if self._lb[0] != np.inf else np.array([1])) result = p_upper - p_lower return result.reshape(X_shape[:-1]) - else: - result = np.ones(X.shape[0]) - for j, gp in enumerate(self._model): - y_mean, y_std = gp.predict(X, return_std=True) - p_lower = (norm(loc=y_mean, scale=y_std).cdf(self._lb[j]) - if self._lb[j] != -np.inf else np.array([0])) - p_upper = (norm(loc=y_mean, scale=y_std).cdf(self._ub[j]) - if self._lb[j] != np.inf else np.array([1])) - result = result * (p_upper - p_lower) - return result.reshape(X_shape[:-1]) + + result = np.ones(X.shape[0]) + for j, gp in enumerate(self._model): + y_mean, y_std = gp.predict(X, return_std=True) + p_lower = (norm(loc=y_mean, scale=y_std).cdf(self._lb[j]) + if self._lb[j] != -np.inf else np.array([0])) + p_upper = (norm(loc=y_mean, scale=y_std).cdf(self._ub[j]) + if self._lb[j] != np.inf else np.array([1])) + result = result * (p_upper - p_lower) + return result.reshape(X_shape[:-1]) def approx(self, X): """ - Returns the approximation of the constraint function using the internal - Gaussian Process Regressors. + Approximate the constraint function using the internal GPR model. + + Parameters + ---------- + X : np.ndarray of shape (n_samples, n_features) + Parameters for which to estimate the constraint function value. + + Returns + ------- + np.ndarray of shape (n_samples, n_constraints) + Constraint function value estimates. """ X_shape = X.shape X = X.reshape((-1, self._model[0].n_features_in_)) if len(self._model) == 1: return self._model[0].predict(X).reshape(X_shape[:-1]) - else: - result = np.column_stack([gp.predict(X) for gp in self._model]) - return result.reshape(X_shape[:-1] + (len(self._lb), )) + + result = np.column_stack([gp.predict(X) for gp in self._model]) + return result.reshape(X_shape[:-1] + (len(self._lb), )) def allowed(self, constraint_values): - """ - Checks whether `constraint_values` are below the specified limits. + """Check whether `constraint_values` fulfills the specified limits. + + Parameters + ---------- + constraint_values : np.ndarray of shape (n_samples, n_constraints) + The values of the constraint function. + + + Returns + ------- + np.ndarrray of shape (n_samples,) + Specifying wheter the constraints are fulfilled. + """ if self._lb.size == 1: return (np.less_equal(self._lb, constraint_values) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index dea99f976..195474cb2 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -1,20 +1,39 @@ +"""Manages the optimization domain and holds points.""" import numpy as np -from .util import ensure_rng, NotUniqueError from colorama import Fore +from .util import ensure_rng, NotUniqueError def _hashable(x): - """ ensure that an point is hashable by a python dict """ + """Ensure that a point is hashable by a python dict.""" return tuple(map(float, x)) -class TargetSpace(object): - """ - Holds the param-space coordinates (X) and target values (Y) - Allows for constant-time appends while ensuring no duplicates are added +class TargetSpace(): + """Holds the param-space coordinates (X) and target values (Y). + + Allows for constant-time appends. + + Parameters + ---------- + target_func : function + Function to be maximized. + + pbounds : dict + Dictionary with parameters names as keys and a tuple with minimum + and maximum values. + + random_state : int, RandomState, or None + optionally specify a seed for a random number generator - Example - ------- + allow_duplicate_points: bool, optional (default=False) + If True, the optimizer will allow duplicate points to be registered. + This behavior may be desired in high noise situations where repeatedly probing + the same point will give different answers. In other situations, the acquisition + may occasionally generate a duplicate point. + + Examples + -------- >>> def target_func(p1, p2): >>> return p1 + p2 >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} @@ -26,25 +45,6 @@ class TargetSpace(object): def __init__(self, target_func, pbounds, constraint=None, random_state=None, allow_duplicate_points=False): - """ - Parameters - ---------- - target_func : function - Function to be maximized. - - pbounds : dict - Dictionary with parameters names as keys and a tuple with minimum - and maximum values. - - random_state : int, RandomState, or None - optionally specify a seed for a random number generator - - allow_duplicate_points: bool, optional (default=False) - If True, the optimizer will allow duplicate points to be registered. - This behavior may be desired in high noise situations where repeatedly probing - the same point will give different answers. In other situations, the acquisition - may occasionally generate a duplicate point. - """ self.random_state = ensure_rng(random_state) self._allow_duplicate_points = allow_duplicate_points self.n_duplicate_points = 0 @@ -62,7 +62,7 @@ def __init__(self, target_func, pbounds, constraint=None, random_state=None, # preallocated memory for X and Y points self._params = np.empty(shape=(0, self.dim)) - self._target = np.empty(shape=(0)) + self._target = np.empty(shape=(0,)) # keep track of unique points we have seen so far self._cache = {} @@ -77,63 +77,149 @@ def __init__(self, target_func, pbounds, constraint=None, random_state=None, self._constraint_values = np.empty(shape=(0, constraint.lb.size), dtype=float) def __contains__(self, x): + """Check if this parameter has already been registered. + + Returns + ------- + bool + """ return _hashable(x) in self._cache def __len__(self): + """Return number of observations registered. + + Returns + ------- + int + """ assert len(self._params) == len(self._target) return len(self._target) @property def empty(self): + """Check if anything has been registered. + + Returns + ------- + bool + """ return len(self) == 0 @property def params(self): + """Get the parameter values registered to this TargetSpace. + + Returns + ------- + np.ndarray + """ return self._params @property def target(self): + """Get the target function values registered to this TargetSpace. + + Returns + ------- + np.ndarray + """ return self._target @property def dim(self): + """Get the number of parameter names. + + Returns + ------- + int + """ return len(self._keys) @property def keys(self): + """Get the keys (or parameter names). + + Returns + ------- + list of str + """ return self._keys @property def bounds(self): + """Get the bounds of this TargetSpace. + + Returns + ------- + np.ndarray + """ return self._bounds @property def constraint(self): + """Get the constraint model. + + Returns + ------- + ConstraintModel + """ return self._constraint @property def constraint_values(self): - if self._constraint is not None: - return self._constraint_values + """Get the constraint values registered to this TargetSpace. + + Returns + ------- + np.ndarray + """ + if self._constraint is None: + raise AttributeError("TargetSpace belongs to an unconstrained optimization") + + return self._constraint_values def params_to_array(self, params): + """Convert a dict representation of parameters into an array version. + + Parameters + ---------- + params : dict + a single point, with len(x) == self.dim. + + Returns + ------- + np.ndarray + Representation of the parameters as dictionary. + """ try: assert set(params) == set(self.keys) - except AssertionError: + except AssertionError as e: raise ValueError( - "Parameters' keys ({}) do ".format(sorted(params)) + - "not match the expected set of keys ({}).".format(self.keys) - ) + f"Parameters' keys ({sorted(params)}) do " + + f"not match the expected set of keys ({self.keys})." + ) from e return np.asarray([params[key] for key in self.keys]) def array_to_params(self, x): + """Convert an array representation of parameters into a dict version. + + Parameters + ---------- + x : np.ndarray + a single point, with len(x) == self.dim. + + Returns + ------- + dict + Representation of the parameters as dictionary. + """ try: assert len(x) == len(self.keys) - except AssertionError: + except AssertionError as e: raise ValueError( - "Size of array ({}) is different than the ".format(len(x)) + - "expected number of parameters ({}).".format(len(self.keys)) - ) + f"Size of array ({len(x)}) is different than the " + + f"expected number of parameters ({len(self.keys)})." + ) from e return dict(zip(self.keys, x)) def _as_array(self, x): @@ -145,20 +231,20 @@ def _as_array(self, x): x = x.ravel() try: assert x.size == self.dim - except AssertionError: + except AssertionError as e: raise ValueError( - "Size of array ({}) is different than the ".format(len(x)) + - "expected number of parameters ({}).".format(len(self.keys))) + f"Size of array ({len(x)}) is different than the " + + f"expected number of parameters ({len(self.keys)})." + ) from e return x def register(self, params, target, constraint_value=None): - """ - Append a point and its target value to the known data. + """Append a point and its target value to the known data. Parameters ---------- - x : ndarray - a single point, with len(x) == self.dim + x : np.ndarray + a single point, with len(x) == self.dim. y : float target function value @@ -172,8 +258,8 @@ def register(self, params, target, constraint_value=None): ----- runs in amortized constant time - Example - ------- + Examples + -------- >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} >>> space = TargetSpace(lambda p1, p2: p1 + p2, pbounds) >>> len(space) @@ -188,11 +274,12 @@ def register(self, params, target, constraint_value=None): if x in self: if self._allow_duplicate_points: self.n_duplicate_points = self.n_duplicate_points + 1 - print(Fore.RED + f'Data point {x} is not unique. {self.n_duplicate_points} duplicates registered.' - f' Continuing ...') + + print(Fore.RED + f'Data point {x} is not unique. {self.n_duplicate_points}' + ' duplicates registered. Continuing ...') else: - raise NotUniqueError(f'Data point {x} is not unique. You can set "allow_duplicate_points=True" to ' - f'avoid this error') + raise NotUniqueError(f'Data point {x} is not unique. You can set' + ' "allow_duplicate_points=True" to avoid this error') self._params = np.concatenate([self._params, x.reshape(1, -1)]) self._target = np.concatenate([self._target, [target]]) @@ -211,17 +298,15 @@ def register(self, params, target, constraint_value=None): [constraint_value]]) def probe(self, params): - """ - Evaluates a single point x, to obtain the value y and then records them - as observations. + """Evaluate the target function on a point and register the result. Notes ----- - If x has been previously seen returns a cached value of y. + If `params` has been previously seen returns a cached value of `y`. Parameters ---------- - x : ndarray + params : np.ndarray a single point, with len(x) == self.dim Returns @@ -236,22 +321,21 @@ def probe(self, params): if self._constraint is None: self.register(x, target) return target - else: - constraint_value = self._constraint.eval(**params) - self.register(x, target, constraint_value) - return target, constraint_value + + constraint_value = self._constraint.eval(**params) + self.register(x, target, constraint_value) + return target, constraint_value def random_sample(self): - """ - Creates random points within the bounds of the space. + """Create random points within the bounds of the space. Returns - ---------- - data: ndarray + ------- + data: np.ndarray [num x dim] array points with dimensions corresponding to `self._keys` - Example - ------- + Examples + -------- >>> target_func = lambda p1, p2: p1 + p2 >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} >>> space = TargetSpace(target_func, pbounds, random_state=0) @@ -267,7 +351,15 @@ def _target_max(self): """Get maximum target value found. If there is a constraint present, the maximum value that fulfills the - constraint is returned.""" + constraint is returned. + + + Returns + ------- + dict | None + The maximum allowed point's target function value. + Returns None if there is no (allowed) maximum. + """ if len(self.target) == 0: return None @@ -284,7 +376,15 @@ def max(self): """Get maximum target value found and corresponding parameters. If there is a constraint present, the maximum value that fulfills the - constraint is returned.""" + constraint is returned. + + Returns + ------- + dict | None + A dictionary containing the maximum allowed point's target function + value, parameters, and, if applicable, constraint function value. + Returns None if there is no (allowed) maximum. + """ target_max = self._target_max() if target_max is None: @@ -299,10 +399,9 @@ def max(self): else: target = self.target params = self.params - constraint_values = self.constraint_values - + target_max_idx = np.where(target == target_max)[0][0] - + res = { 'target': target_max, @@ -318,6 +417,12 @@ def max(self): def res(self): """Get all target values and constraint fulfillment for all parameters. + + Returns + ------- + dict + A dictionary containing the target function values, parameters, + and, if applicable, constraint function values and allowedness. """ if self._constraint is None: params = [dict(zip(self.keys, p)) for p in self.params] @@ -326,27 +431,26 @@ def res(self): {"target": target, "params": param} for target, param in zip(self.target, params) ] - else: - params = [dict(zip(self.keys, p)) for p in self.params] - return [ - { - "target": target, - "constraint": constraint_value, - "params": param, - "allowed": allowed - } - for target, constraint_value, param, allowed in zip( - self.target, - self._constraint_values, - params, - self._constraint.allowed(self._constraint_values) - ) - ] + params = [dict(zip(self.keys, p)) for p in self.params] + + return [ + { + "target": target, + "constraint": constraint_value, + "params": param, + "allowed": allowed + } + for target, constraint_value, param, allowed in zip( + self.target, + self._constraint_values, + params, + self._constraint.allowed(self._constraint_values) + ) + ] def set_bounds(self, new_bounds): - """ - A method that allows changing the lower and upper searching bounds + """Change the lower and upper search bounds. Parameters ---------- From 77c71116f4d83121dd9be5765ab13096d3ae3219 Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Sat, 14 Oct 2023 13:02:22 +0200 Subject: [PATCH 03/13] Update various docstrings, add workflow to check docstrings (#445) * Fixes issue-436: Constrained optimization does not allow duplicate points (#437) * Update docs of `bayesian_optimization.py` and `observer.py`. * Fix minor style issue in module docstring * Update docs of `__init__.py` and `events.py`. * Fix minor style issue in class docstring * Add workflow to check docstrings * Update bayes_opt/bayesian_optimization.py Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> --------- Co-authored-by: YoungJae Bae <57710489+YoungJaeBae@users.noreply.github.com> Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> --- .github/workflows/check_docstrings.yml | 30 +++++++++ bayes_opt/__init__.py | 1 + bayes_opt/bayesian_optimization.py | 85 ++++++++++++++++++++------ bayes_opt/event.py | 7 +++ bayes_opt/observer.py | 23 ++++--- 5 files changed, 119 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/check_docstrings.yml diff --git a/.github/workflows/check_docstrings.yml b/.github/workflows/check_docstrings.yml new file mode 100644 index 000000000..4f6e8ce94 --- /dev/null +++ b/.github/workflows/check_docstrings.yml @@ -0,0 +1,30 @@ +# This workflow will install Python dependencies and check docstrings with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Check docstrings + +on: + push: + branches: [ "master" ] + pull_request: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pydocstyle + - name: Check docstyle + run : pydocstyle --convention=numpy bayes_opt/* + #- name: Run linting + # run : pylint bayes_opt/* --disable=C0103 # ignore no snake_case conformity of arguments diff --git a/bayes_opt/__init__.py b/bayes_opt/__init__.py index 3c9d4791c..50cd81bcb 100644 --- a/bayes_opt/__init__.py +++ b/bayes_opt/__init__.py @@ -1,3 +1,4 @@ +"""Pure Python implementation of bayesian global optimization with gaussian processes.""" from .bayesian_optimization import BayesianOptimization, Events from .domain_reduction import SequentialDomainReductionTransformer from .util import UtilityFunction diff --git a/bayes_opt/bayesian_optimization.py b/bayes_opt/bayesian_optimization.py index 97a7b9de1..da0702a8d 100644 --- a/bayes_opt/bayesian_optimization.py +++ b/bayes_opt/bayesian_optimization.py @@ -1,3 +1,8 @@ +"""Main module. + +Holds the `BayesianOptimization` class, which handles the maximization of a +function over a specific target space. +""" import warnings from bayes_opt.constraint import ConstraintModel @@ -12,17 +17,25 @@ class Queue: + """Queue datastructure. + + Append items in the end, remove items from the front. + """ + def __init__(self): self._queue = [] @property def empty(self): + """Check whether the queue holds any items.""" return len(self) == 0 def __len__(self): + """Return number of items in the Queue.""" return len(self._queue) def __next__(self): + """Remove and return first item in the Queue.""" if self.empty: raise StopIteration("Queue is empty, no more objects to retrieve.") obj = self._queue[0] @@ -35,11 +48,7 @@ def add(self, obj): class Observable(object): - """ - - Inspired/Taken from - https://www.protechtraining.com/blog/post/879#simple-observer - """ + """Inspired by https://www.protechtraining.com/blog/post/879#simple-observer.""" def __init__(self, events): # maps event names to subscribers @@ -47,23 +56,28 @@ def __init__(self, events): self._events = {event: dict() for event in events} def get_subscribers(self, event): + """Return the subscribers of an event.""" return self._events[event] def subscribe(self, event, subscriber, callback=None): + """Add subscriber to an event.""" if callback is None: callback = getattr(subscriber, 'update') self.get_subscribers(event)[subscriber] = callback def unsubscribe(self, event, subscriber): + """Remove a subscriber for a particular event.""" del self.get_subscribers(event)[subscriber] def dispatch(self, event): + """Trigger callbacks for subscribers of an event.""" for _, callback in self.get_subscribers(event).items(): callback(event, self) class BayesianOptimization(Observable): - """ + """Handle optimization of a target function over a specific target space. + This class takes the function to optimize as well as the parameters bounds in order to find which values for the parameters yield the maximum value using bayesian optimization. @@ -150,7 +164,8 @@ def __init__(self, f, pbounds, constraint=constraint_, - random_state=random_state + random_state=random_state, + allow_duplicate_points=self._allow_duplicate_points ) self.is_constrained = True @@ -167,30 +182,53 @@ def __init__(self, @property def space(self): + """Return the target space associated with the optimizer.""" return self._space @property def constraint(self): + """Return the constraint associated with the optimizer, if any.""" if self.is_constrained: return self._space.constraint return None @property def max(self): + """Get maximum target value found and corresponding parameters. + + See `TargetSpace.max` for more information. + """ return self._space.max() @property def res(self): + """Get all target values and constraint fulfillment for all parameters. + + See `TargetSpace.res` for more information. + """ return self._space.res() def register(self, params, target, constraint_value=None): - """Expect observation with known target""" + """Register an observation with known target. + + Parameters + ---------- + params: dict or list + The parameters associated with the observation. + + target: float + Value of the target function at the observation. + + constraint_value: float or None + Value of the constraint function at the observation, if any. + """ self._space.register(params, target, constraint_value) self.dispatch(Events.OPTIMIZATION_STEP) def probe(self, params, lazy=True): - """ - Evaluates the function on the given points. Useful to guide the optimizer. + """Evaluate the function at the given points. + + Useful to guide the optimizer. Parameters ---------- @@ -201,7 +239,6 @@ def probe(self, params, lazy=True): If True, the optimizer will evaluate the points when calling maximize(). Otherwise it will evaluate it at the moment. """ - if lazy: self._queue.add(params) else: @@ -209,7 +246,14 @@ def probe(self, params, lazy=True): self.dispatch(Events.OPTIMIZATION_STEP) def suggest(self, utility_function): - """Most promising point to probe next""" + """Suggest a promising point to probe next. + + Parameters + ---------- + utility_function: + Surrogate function which suggests parameters to probe the target + function at. + """ if len(self._space) == 0: return self._space.array_to_params(self._space.random_sample()) @@ -233,7 +277,13 @@ def suggest(self, utility_function): return self._space.array_to_params(suggestion) def _prime_queue(self, init_points): - """Make sure there's something in the queue at the very beginning.""" + """Ensure the queue is not empty. + + Parameters + ---------- + init_points: int + Number of parameters to prime the queue with. + """ if self._queue.empty and self._space.empty: init_points = max(init_points, 1) @@ -257,10 +307,8 @@ def maximize(self, kappa_decay_delay=None, xi=None, **gp_params): - """ - Probes the target space to find the parameters that yield the maximum - value for the given function. + Maximize the given function over the target space. Parameters ---------- @@ -318,8 +366,7 @@ def maximize(self, self.dispatch(Events.OPTIMIZATION_END) def set_bounds(self, new_bounds): - """ - A method that allows changing the lower and upper searching bounds + """Modify the bounds of the search space. Parameters ---------- @@ -329,5 +376,5 @@ def set_bounds(self, new_bounds): self._space.set_bounds(new_bounds) def set_gp_params(self, **params): - """Set parameters to the internal Gaussian Process Regressor""" + """Set parameters of the internal Gaussian Process Regressor.""" self._gp.set_params(**params) diff --git a/bayes_opt/event.py b/bayes_opt/event.py index d5dfdd10e..374534343 100644 --- a/bayes_opt/event.py +++ b/bayes_opt/event.py @@ -1,4 +1,11 @@ +"""Register optimization events variables.""" + class Events: + """Define optimization events. + + Behaves similar to enums. + """ + OPTIMIZATION_START = 'optimization:start' OPTIMIZATION_STEP = 'optimization:step' OPTIMIZATION_END = 'optimization:end' diff --git a/bayes_opt/observer.py b/bayes_opt/observer.py index 5a6ac16b2..910b8c370 100644 --- a/bayes_opt/observer.py +++ b/bayes_opt/observer.py @@ -1,16 +1,11 @@ -""" -observers... -""" +"""Holds the parent class for loggers.""" from datetime import datetime from .event import Events -class Observer: - def update(self, event, instance): - raise NotImplementedError - - class _Tracker(object): + """Parent class for ScreenLogger and JSONLogger.""" + def __init__(self): self._iterations = 0 @@ -21,6 +16,17 @@ def __init__(self): self._previous_time = None def _update_tracker(self, event, instance): + """Update the tracker. + + Parameters + ---------- + event : str + One of the values associated with `Events.OPTIMIZATION_START`, + `Events.OPTIMIZATION_STEP` or `Events.OPTIMIZATION_END`. + + instance : bayesian_optimization.BayesianOptimization + The instance associated with the step. + """ if event == Events.OPTIMIZATION_STEP: self._iterations += 1 @@ -35,6 +41,7 @@ def _update_tracker(self, event, instance): self._previous_max_params = current_max["params"] def _time_metrics(self): + """Return time passed since last call.""" now = datetime.now() if self._start_time is None: self._start_time = now From a4df58c86372a3e9bba00d0d38cec8ce110c012c Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Sun, 10 Dec 2023 16:49:57 +0100 Subject: [PATCH 04/13] Pydocstyle (#453) * Improve acq_max seeding of L-BFGS-B optimization (#297) --------- Co-authored-by: ptapping <63924582+ptapping@users.noreply.github.com> --- bayes_opt/bayesian_optimization.py | 3 ++- bayes_opt/util.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bayes_opt/bayesian_optimization.py b/bayes_opt/bayesian_optimization.py index da0702a8d..3c20eab6d 100644 --- a/bayes_opt/bayesian_optimization.py +++ b/bayes_opt/bayesian_optimization.py @@ -272,7 +272,8 @@ def suggest(self, utility_function): constraint=self.constraint, y_max=self._space._target_max(), bounds=self._space.bounds, - random_state=self._random_state) + random_state=self._random_state, + y_max_params=self._space.params_to_array(self._space.max()['params'])) return self._space.array_to_params(suggestion) diff --git a/bayes_opt/util.py b/bayes_opt/util.py index d8a4f9077..417e307f7 100644 --- a/bayes_opt/util.py +++ b/bayes_opt/util.py @@ -6,7 +6,7 @@ from scipy.optimize import minimize -def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10): +def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10, y_max_params=None): """Find the maximum of the acquisition function. It uses a combination of random sampling (cheap) and the 'L-BFGS-B' @@ -44,6 +44,9 @@ def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000 n_iter : int, default=10 Points to run L-BFGS-B optimization from. + y_max_params : np.array + Function parameters that produced the maximum known value given by `y_max`. + Returns ------- Parameters maximizing the acquisition function. @@ -101,7 +104,14 @@ def adjusted_ac(x): # Explore the parameter space more thoroughly x_seeds = random_state.uniform(bounds[:, 0], bounds[:, 1], - size=(n_iter, bounds.shape[0])) + size=(1+n_iter+int(not y_max_params is None), + bounds.shape[0])) + + x_seeds[0] = x_max + if not y_max_params is None: + # Add the provided best sample to the seeds so that the optimization + # algorithm is aware of it and will attempt to find its local maxima + x_seeds[1] = y_max_params for x_try in x_seeds: # Find the minimum of minus the acquisition function From a58ecaf65e494a6a94788a8905469d20289cd558 Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:28:19 +0100 Subject: [PATCH 05/13] Domain reduction, Sphinx docs (#455) * Fixes issue-436: Constrained optimization does not allow duplicate points (#437) * Update docs of `bayesian_optimization.py` and `observer.py`. * Fix minor style issue in module docstring * Update docs of `__init__.py` and `events.py`. * Fix minor style issue in class docstring * Add workflow to check docstrings * Update bayes_opt/bayesian_optimization.py Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> * Improve acq_max seeding of L-BFGS-B optimization (#297) * bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py (#441) * Update trim bounds in domain_reduction.py Previously, when the new upper limit was less than the original lower limit, the new_bounds could bypass the global_bounds. * Update test_seq_domain_red.py Added test cases to catch an error when both bounds of new_bounds exceeded the global_bounds * Update domain_reduction.py _trim function now avoids an error when both bounds for a given parameter in new_bounds exceed the global_bounds * Update domain_reduction.py comments * fixed English in domain_reduction.py * use numpy to sort bounds, boundary exceeded warn. * simple sort test added * domain_red windows target_space to global_bounds Added windowing function to improve the convergence of optimizers that use domain_reduction. Improved comments and documentation. * target_space.max respects bounds; SDRT warnings * Remove unused function. This function was used to prototype a solution. It should not have been pushed and can be removed. * Updated target_space.py docstrings * Update tests/test_target_space.py Co-authored-by: till-m <36440677+till-m@users.noreply.github.com> * Added pbound warnings, updated various tests. * updated line spacing for consistency and style * added pbound test condition --------- Co-authored-by: till-m <36440677+till-m@users.noreply.github.com> * DomainReduction docs, docstyle * Add missing doc dependency --------- Co-authored-by: YoungJae Bae <57710489+YoungJaeBae@users.noreply.github.com> Co-authored-by: Leandro Braga <18340809+leandrobbraga@users.noreply.github.com> Co-authored-by: ptapping <63924582+ptapping@users.noreply.github.com> Co-authored-by: Edgar <50716923+perezed00@users.noreply.github.com> --- .github/workflows/build_docs.yml | 2 + .gitignore | 4 +- README.md | 137 +++++++++-------- bayes_opt/constraint.py | 2 +- bayes_opt/domain_reduction.py | 141 +++++++++++++----- bayes_opt/target_space.py | 129 ++++++++++------ bayes_opt/util.py | 3 +- docsrc/Makefile | 2 + docsrc/conf.py | 5 +- docsrc/func.ico | Bin 0 -> 136207 bytes docsrc/index.rst | 1 + docsrc/quickstart.rst | 2 + examples/domain_reduction.ipynb | 2 +- .../bayesian_optimization.gif | Bin {examples => static}/bo_example.png | Bin {examples => static}/func.png | Bin {examples => static}/sdr.png | Bin tests/test_logs_bounds.log | 5 + tests/test_seq_domain_red.py | 51 ++++++- tests/test_target_space.py | 38 ++++- tests/test_util.py | 22 ++- 21 files changed, 386 insertions(+), 160 deletions(-) create mode 100644 docsrc/func.ico create mode 100644 docsrc/quickstart.rst rename {examples => static}/bayesian_optimization.gif (100%) rename {examples => static}/bo_example.png (100%) rename {examples => static}/func.png (100%) rename {examples => static}/sdr.png (100%) create mode 100644 tests/test_logs_bounds.log diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 07282413b..a57745b01 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -29,6 +29,8 @@ jobs: pip install nbsphinx pip install sphinx_rtd_theme pip install jupyter + pip install numpydoc + pip install myst-parser - name: Install package run: | pip install -e . diff --git a/.gitignore b/.gitignore index 3f4f6d54e..6556c710e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ venv.bak/ docs/* docsrc/.ipynb_checkpoints/* -docsrc/*.ipynb \ No newline at end of file +docsrc/*.ipynb +docsrc/static/* +docsrc/README.md diff --git a/README.md b/README.md index ac94cc649..652dc9a18 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@
-

+

# Bayesian Optimization -![tests](https://github.com/fmfn/BayesianOptimization/actions/workflows/run_tests.yml/badge.svg) -[![Codecov](https://codecov.io/github/fmfn/BayesianOptimization/badge.svg?branch=master&service=github)](https://codecov.io/github/fmfn/BayesianOptimization?branch=master) +![tests](https://github.com/bayesian-optimization/BayesianOptimization/actions/workflows/run_tests.yml/badge.svg) +[![Codecov](https://codecov.io/github/bayesian-optimization/BayesianOptimization/badge.svg?branch=master&service=github)](https://codecov.io/github/bayesian-optimization/BayesianOptimization?branch=master) [![Pypi](https://img.shields.io/pypi/v/bayesian-optimization.svg)](https://pypi.python.org/pypi/bayesian-optimization) Pure Python implementation of bayesian global optimization with gaussian processes. +## Installation + * PyPI (pip): ```console @@ -30,25 +32,18 @@ suited for optimization of high cost functions, situations where the balance between exploration and exploitation is important. ## Quick Start -See below for a quick tour over the basics of the Bayesian Optimization package. More detailed information, other advanced features, and tips on usage/implementation can be found in the [examples](https://github.com/fmfn/BayesianOptimization/tree/master/examples) folder. I suggest that you: -- Follow the -[basic tour notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/basic-tour.ipynb) -to learn how to use the package's most important features. -- Take a look at the -[advanced tour notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/advanced-tour.ipynb) -to learn how to make the package more flexible, how to deal with categorical parameters, how to use observers, and more. -- Check out this -[notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/visualization.ipynb) -with a step by step visualization of how this method works. -- To understand how to use bayesian optimization when additional constraints are present, see the -[constrained optimization notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/constraints.ipynb). -- Explore this [notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/exploitation_vs_exploration.ipynb) +See below for a quick tour over the basics of the Bayesian Optimization package. More detailed information, other advanced features, and tips on usage/implementation can be found in the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) folder. I suggest that you: +- Follow the [basic tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) to learn how to use the package's most important features. +- Take a look at the [advanced tour notebook](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html) to learn how to make the package more flexible, how to deal with categorical parameters, how to use observers, and more. +- Check out this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/visualization.html) with a step by step visualization of how this method works. +- To understand how to use bayesian optimization when additional constraints are present, see the [constrained optimization notebook](http://bayesian-optimization.github.io/BayesianOptimization/constraints.html). +- Explore this [notebook](http://bayesian-optimization.github.io/BayesianOptimization/exploitation_vs_exploration.html) exemplifying the balance between exploration and exploitation and how to control it. -- Go over this [script](https://github.com/fmfn/BayesianOptimization/blob/master/examples/sklearn_example.py) +- Go over this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/sklearn_example.py) for examples of how to tune parameters of Machine Learning models using cross validation and bayesian optimization. -- Explore the [domain reduction notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/domain_reduction.ipynb) to learn more about how search can be sped up by dynamically changing parameters' bounds. -- Finally, take a look at this [script](https://github.com/fmfn/BayesianOptimization/blob/master/examples/async_optimization.py) +- Explore the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html) to learn more about how search can be sped up by dynamically changing parameters' bounds. +- Finally, take a look at this [script](https://github.com/bayesian-optimization/BayesianOptimization/blob/master/examples/async_optimization.py) for ideas on how to implement bayesian optimization in a distributed fashion using this package. @@ -56,11 +51,11 @@ for ideas on how to implement bayesian optimization in a distributed fashion usi Bayesian optimization works by constructing a posterior distribution of functions (gaussian process) that best describes the function you want to optimize. As the number of observations grows, the posterior distribution improves, and the algorithm becomes more certain of which regions in parameter space are worth exploring and which are not, as seen in the picture below. -![BayesianOptimization in action](./examples/bo_example.png) +![BayesianOptimization in action](./static/bo_example.png) As you iterate over and over, the algorithm balances its needs of exploration and exploitation taking into account what it knows about the target function. At each step a Gaussian Process is fitted to the known samples (points previously explored), and the posterior distribution, combined with a exploration strategy (such as UCB (Upper Confidence Bound), or EI (Expected Improvement)), are used to determine the next point that should be explored (see the gif below). -![BayesianOptimization in action](./examples/bayesian_optimization.gif) +![BayesianOptimization in action](./static/bayesian_optimization.gif) This process is designed to minimize the number of steps required to find a combination of parameters that are close to the optimal combination. To do so, this method uses a proxy optimization problem (finding the maximum of the acquisition function) that, albeit still a hard problem, is cheaper (in the computational sense) and common tools can be employed. Therefore Bayesian Optimization is most adequate for situations where sampling the function to be optimized is a very expensive endeavor. See the references for a proper discussion of this method. @@ -68,10 +63,9 @@ This project is under active development, if you find a bug, or anything that needs correction, please let me know. -Basic tour of the Bayesian Optimization package -=============================================== +## Basic tour of the Bayesian Optimization package -## 1. Specifying the function to be optimized +### 1. Specifying the function to be optimized This is a function optimization package, therefore the first and most important ingredient is, of course, the function to be optimized. @@ -89,7 +83,7 @@ def black_box_function(x, y): return -x ** 2 - (y - 1) ** 2 + 1 ``` -## 2. Getting Started +### 2. Getting Started All we need to get started is to instantiate a `BayesianOptimization` object specifying a function to be optimized `f`, and its parameters with their corresponding bounds, `pbounds`. This is a constrained optimization technique, so you must specify the minimum and maximum values that can be probed for each parameter in order for it to work @@ -160,7 +154,7 @@ for i, res in enumerate(optimizer.res): ``` -### 2.1 Changing bounds +#### 2.1 Changing bounds During the optimization process you may realize the bounds chosen for some parameters are not adequate. For these situations you can invoke the method `set_bounds` to alter them. You can pass any combination of **existing** parameters and their associated new bounds. @@ -183,17 +177,17 @@ optimizer.maximize( | 10 | -1.762 | 1.442 | 0.1735 | ================================================= -### 2.2 Sequential Domain Reduction +#### 2.2 Sequential Domain Reduction Sometimes the initial boundaries specified for a problem are too wide, and adding points to improve the response surface in regions of the solution domain is extraneous. Other times the cost function is very expensive to compute, and minimizing the number of calls is extremely beneficial. When it's worthwhile to converge on an optimal point quickly rather than try to find the optimal point, contracting the domain around the current optimal value as the search progresses can speed up the search progress considerably. Using the `SequentialDomainReductionTransformer` the bounds of the problem can be panned and zoomed dynamically in an attempt to improve convergence. -![sequential domain reduction](./examples/sdr.png) +![sequential domain reduction](./static/sdr.png) -An example of using the `SequentialDomainReductionTransformer` is shown in the [domain reduction notebook](https://github.com/fmfn/BayesianOptimization/blob/master/examples/domain_reduction.ipynb). More information about this method can be found in the paper ["On the robustness of a simple domain reduction scheme for simulation‐based optimization"](http://www.truegrid.com/srsm_revised.pdf). +An example of using the `SequentialDomainReductionTransformer` is shown in the [domain reduction notebook](http://bayesian-optimization.github.io/BayesianOptimization/domain_reduction.html). More information about this method can be found in the paper ["On the robustness of a simple domain reduction scheme for simulation‐based optimization"](http://www.truegrid.com/srsm_revised.pdf). -## 3. Guiding the optimization +### 3. Guiding the optimization It is often the case that we have an idea of regions of the parameter space where the maximum of our function might lie. For these situations the `BayesianOptimization` object allows the user to specify points to be probed. By default these will be explored lazily (`lazy=True`), meaning these points will be evaluated only the next time you call `maximize`. This probing process happens before the gaussian process takes over. @@ -221,11 +215,11 @@ optimizer.maximize(init_points=0, n_iter=0) ================================================= -## 4. Saving, loading and restarting +### 4. Saving, loading and restarting By default you can follow the progress of your optimization by setting `verbose>0` when instantiating the `BayesianOptimization` object. If you need more control over logging/alerting you will need to use an observer. For more information about observers checkout the advanced tour notebook. Here we will only see how to use the native `JSONLogger` object to save to and load progress from files. -### 4.1 Saving progress +#### 4.1 Saving progress ```python @@ -255,7 +249,7 @@ optimizer.maximize( By default the previous data in the json file is removed. If you want to keep working with the same logger, the `reset` parameter in `JSONLogger` should be set to False. -### 4.2 Loading progress +#### 4.2 Loading progress Naturally, if you stored progress you will be able to load that onto a new instance of `BayesianOptimization`. The easiest way to do it is by invoking the `load_logs` function, from the `util` submodule. @@ -277,54 +271,71 @@ load_logs(new_optimizer, logs=["./logs.log"]); ## Next Steps -This introduction covered the most basic functionality of the package. Checkout the [basic-tour](https://github.com/fmfn/BayesianOptimization/blob/master/examples/basic-tour.ipynb) and [advanced-tour](https://github.com/fmfn/BayesianOptimization/blob/master/examples/advanced-tour.ipynb) notebooks in the example folder, where you will find detailed explanations and other more advanced functionality. Also, browse the examples folder for implementation tips and ideas. - -Installation -============ - -### Installation - -The latest release can be obtained by two ways: - -* With PyPI (pip): - - pip install bayesian-optimization +This introduction covered the most basic functionality of the package. Checkout the [basic-tour](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) and [advanced-tour](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html), where you will find detailed explanations and other more advanced functionality. Also, browse the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) for implementation tips and ideas. -* With conda (from conda-forge channel): - - conda install -c conda-forge bayesian-optimization - -The bleeding edge version can be installed with: - - pip install git+https://github.com/fmfn/BayesianOptimization.git +## Installing from GitHub +To install directly from master, simply run +``` +pip install https://github.com/bayesian-optimization/BayesianOptimization/archive/master.zip +``` +Please note that these builds are not necessarily stable. -If you prefer, you can clone it and run the setup.py file. Use the following -commands to get a copy from Github and install all dependencies: +If you prefer, you can also clone the repository and run `setup.py`: +``` +git clone https://github.com/bayesian-optimization/BayesianOptimization.git +cd BayesianOptimization +python setup.py install +``` + - git clone https://github.com/fmfn/BayesianOptimization.git - cd BayesianOptimization - python setup.py install +## Minutiae -Citation -============ +### Citation -If you used this package in your research and is interested in citing it here's how you do it: +If you used this package in your research, please cite it: ``` @Misc{, author = {Fernando Nogueira}, title = {{Bayesian Optimization}: Open source constrained global optimization tool for {Python}}, year = {2014--}, - url = " https://github.com/fmfn/BayesianOptimization" + url = " https://github.com/bayesian-optimization/BayesianOptimization" +} +``` +If you used any of the advanced functionalities, please additionally cite the corresponding publication: + +For the `SequentialDomainTransformer`: +``` +@article{ + author = {Stander, Nielen and Craig, Kenneth}, + year = {2002}, + month = {06}, + pages = {}, + title = {On the robustness of a simple domain reduction scheme for simulation-based optimization}, + volume = {19}, + journal = {International Journal for Computer-Aided Engineering and Software (Eng. Comput.)}, + doi = {10.1108/02644400210430190} +} +``` + +For constrained optimization: +``` +@inproceedings{gardner2014bayesian, + title={Bayesian optimization with inequality constraints.}, + author={Gardner, Jacob R and Kusner, Matt J and Xu, Zhixiang Eddie and Weinberger, Kilian Q and Cunningham, John P}, + booktitle={ICML}, + volume={2014}, + pages={937--945}, + year={2014} } ``` -# Dependencies +### Dependencies * Numpy * Scipy * Scikit-learn -# References: +### References: * http://papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf * http://arxiv.org/pdf/1012.2599v1.pdf * http://www.gaussianprocess.org/gpml/ diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index 5ea333525..10142e43b 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -81,7 +81,7 @@ def eval(self, **kwargs): Raises ------ TypeError - If the kwargs keys don't match the function argument names. + If the kwargs' keys don't match the function argument names. """ try: return self.fun(**kwargs) diff --git a/bayes_opt/domain_reduction.py b/bayes_opt/domain_reduction.py index f4b86ffc8..f1d31a418 100644 --- a/bayes_opt/domain_reduction.py +++ b/bayes_opt/domain_reduction.py @@ -1,26 +1,37 @@ +"""Implement domain transformation. + +In particular, this provides a base transformer class and a sequential domain +reduction transformer as based on Stander and Craig's "On the robustness of a +simple domain reduction scheme for simulation-based optimization" +""" from typing import Optional, Union, List import numpy as np from .target_space import TargetSpace +from warnings import warn class DomainTransformer(): - '''The base transformer class''' + """Base class.""" - def __init__(self, **kwargs): + def __init__(self, **kwargs) -> None: + """To override with specific implementation.""" pass - def initialize(self, target_space: TargetSpace): + def initialize(self, target_space: TargetSpace) -> None: + """To override with specific implementation.""" raise NotImplementedError - def transform(self, target_space: TargetSpace): + def transform(self, target_space: TargetSpace) -> dict: + """To override with specific implementation.""" raise NotImplementedError class SequentialDomainReductionTransformer(DomainTransformer): - """ + """Reduce the searchable space. + A sequential domain reduction transformer based on the work by Stander, N. and Craig, K: - "On the robustness of a simple domain reduction scheme for simulation‐based optimization" + "On the robustness of a simple domain reduction scheme for simulation-based optimization" """ def __init__( @@ -36,7 +47,14 @@ def __init__( self.minimum_window_value = minimum_window def initialize(self, target_space: TargetSpace) -> None: - """Initialize all of the parameters""" + """Initialize all of the parameters. + + Parameters + ---------- + target_space : TargetSpace + TargetSpace this DomainTransformer operates on. + """ + # Set the original bounds self.original_bounds = np.copy(target_space.bounds) self.bounds = [self.original_bounds] @@ -47,6 +65,7 @@ def initialize(self, target_space: TargetSpace) -> None: else: self.minimum_window = [self.minimum_window_value] * len(target_space.bounds) + # Set initial values self.previous_optimal = np.mean(target_space.bounds, axis=1) self.current_optimal = np.mean(target_space.bounds, axis=1) self.r = target_space.bounds[:, 1] - target_space.bounds[:, 0] @@ -72,14 +91,12 @@ def initialize(self, target_space: TargetSpace) -> None: self._window_bounds_compatibility(self.original_bounds) def _update(self, target_space: TargetSpace) -> None: - + """Update contraction rate, window size, and window center.""" # setting the previous self.previous_optimal = self.current_optimal self.previous_d = self.current_d - - self.current_optimal = target_space.params[ - np.argmax(target_space.target) - ] + + self.current_optimal = target_space.params_to_array(target_space.max()['params']) self.current_d = 2.0 * (self.current_optimal - self.previous_optimal) / self.r @@ -97,32 +114,82 @@ def _update(self, target_space: TargetSpace) -> None: self.r = self.contraction_rate * self.r def _trim(self, new_bounds: np.array, global_bounds: np.array) -> np.array: - for i, variable in enumerate(new_bounds): - if variable[0] < global_bounds[i, 0]: - variable[0] = global_bounds[i, 0] - if variable[1] > global_bounds[i, 1]: - variable[1] = global_bounds[i, 1] - for i, entry in enumerate(new_bounds): - if entry[0] > entry[1]: - new_bounds[i, 0] = entry[1] - new_bounds[i, 1] = entry[0] - window_width = abs(entry[0] - entry[1]) - if window_width < self.minimum_window[i]: - dw = (self.minimum_window[i] - window_width) / 2.0 - left_expansion_space = abs(global_bounds[i, 0] - entry[0]) # should be non-positive - right_expansion_space = abs(global_bounds[i, 1] - entry[1]) # should be non-negative - # conservative - dw_l = min(dw, left_expansion_space) - dw_r = min(dw, right_expansion_space) - # this crawls towards the edge - ddw_r = dw_r + max(dw - dw_l, 0) - ddw_l = dw_l + max(dw - dw_r, 0) - new_bounds[i, 0] -= ddw_l - new_bounds[i, 1] += ddw_r + """ + Adjust the new_bounds and verify that they adhere to global_bounds and minimum_window. + + Parameters + ---------- + new_bounds : np.array + The proposed new_bounds that (may) need adjustment. + + global_bounds : np.array + The maximum allowable bounds for each parameter. + + Returns + ------- + new_bounds : np.array + The adjusted bounds after enforcing constraints. + """ + #sort bounds + new_bounds = np.sort(new_bounds) + + # Validate each parameter's bounds against the global_bounds + for i, pbounds in enumerate(new_bounds): + # If the one of the bounds is outside the global bounds, reset the bound to the global bound + # This is expected to happen when the window is near the global bounds, no warning is issued + if (pbounds[0] < global_bounds[i, 0]): + pbounds[0] = global_bounds[i, 0] + + if (pbounds[1] > global_bounds[i, 1]): + pbounds[1] = global_bounds[i, 1] + + # If a lower bound is greater than the associated global upper bound, reset it to the global lower bound + if (pbounds[0] > global_bounds[i, 1]): + pbounds[0] = global_bounds[i, 0] + warn("\nDomain Reduction Warning:\n"+ + "A parameter's lower bound is greater than the global upper bound."+ + "The offensive boundary has been reset."+ + "Be cautious of subsequent reductions.", stacklevel=2) + + # If an upper bound is less than the associated global lower bound, reset it to the global upper bound + if (pbounds[1] < global_bounds[i, 0]): + pbounds[1] = global_bounds[i, 1] + warn("\nDomain Reduction Warning:\n"+ + "A parameter's lower bound is greater than the global upper bound."+ + "The offensive boundary has been reset."+ + "Be cautious of subsequent reductions.", stacklevel=2) + + # Adjust new_bounds to ensure they respect the minimum window width for each parameter + for i, pbounds in enumerate(new_bounds): + current_window_width = abs(pbounds[0] - pbounds[1]) + + # If the window width is less than the minimum allowable width, adjust it + # Note that when minimum_window < width of the global bounds one side always has more space than required + if current_window_width < self.minimum_window[i]: + width_deficit = (self.minimum_window[i] - current_window_width) / 2.0 + available_left_space = abs(global_bounds[i, 0] - pbounds[0]) + available_right_space = abs(global_bounds[i, 1] - pbounds[1]) + + # determine how much to expand on the left and right + expand_left = min(width_deficit, available_left_space) + expand_right = min(width_deficit, available_right_space) + + # calculate the deficit on each side + expand_left_deficit = width_deficit - expand_left + expand_right_deficit = width_deficit - expand_right + + # shift the deficit to the side with more space + adjust_left = expand_left + max(expand_right_deficit, 0) + adjust_right = expand_right + max(expand_left_deficit, 0) + + # adjust the bounds + pbounds[0] -= adjust_left + pbounds[1] += adjust_right + return new_bounds def _window_bounds_compatibility(self, global_bounds: np.array) -> bool: - """Checks if global bounds are compatible with the minimum window sizes.""" + """Check if global bounds are compatible with the minimum window sizes.""" for i, entry in enumerate(global_bounds): global_window_width = abs(entry[1] - entry[0]) if global_window_width < self.minimum_window[i]: @@ -133,7 +200,7 @@ def _create_bounds(self, parameters: dict, bounds: np.array) -> dict: return {param: bounds[i, :] for i, param in enumerate(parameters)} def transform(self, target_space: TargetSpace) -> dict: - + """Transform the bounds of the target space.""" self._update(target_space) new_bounds = np.array( @@ -143,6 +210,6 @@ def transform(self, target_space: TargetSpace) -> dict: ] ).T - self._trim(new_bounds, self.original_bounds) + new_bounds = self._trim(new_bounds, self.original_bounds) self.bounds.append(new_bounds) return self._create_bounds(target_space.keys, new_bounds) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 195474cb2..bf727c5c2 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -1,6 +1,7 @@ """Manages the optimization domain and holds points.""" import numpy as np from colorama import Fore +from warnings import warn from .util import ensure_rng, NotUniqueError @@ -38,9 +39,11 @@ class TargetSpace(): >>> return p1 + p2 >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} >>> space = TargetSpace(target_func, pbounds, random_state=0) - >>> x = space.random_points(1)[0] - >>> y = space.register_point(x) - >>> assert self.max_point()['max_val'] == y + >>> x = np.array([4 , 5]) + >>> y = target_func(x) + >>> space.register(x, y) + >>> assert self.max()['target'] == 9 + >>> assert self.max()['params'] == {'p1': 1.0, 'p2': 2.0} """ def __init__(self, target_func, pbounds, constraint=None, random_state=None, @@ -178,6 +181,30 @@ def constraint_values(self): return self._constraint_values + @property + def mask(self): + """Return a boolean array of valid points. + + Points are valid if they satisfy both the constraint and boundary conditions. + + Returns + ------- + np.ndarray + """ + mask = np.ones_like(self.target, dtype=bool) + + # mask points that don't satisfy the constraint + if self._constraint is not None: + mask &= self._constraint.allowed(self._constraint_values) + + # mask points that are outside the bounds + if self._bounds is not None: + within_bounds = np.all((self._bounds[:, 0] <= self._params) & + (self._params <= self._bounds[:, 1]), axis=1) + mask &= within_bounds + + return mask + def params_to_array(self, params): """Convert a dict representation of parameters into an array version. @@ -260,13 +287,14 @@ def register(self, params, target, constraint_value=None): Examples -------- + >>> target_func = lambda p1, p2: p1 + p2 >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} - >>> space = TargetSpace(lambda p1, p2: p1 + p2, pbounds) + >>> space = TargetSpace(target_func, pbounds) >>> len(space) 0 >>> x = np.array([0, 0]) >>> y = 1 - >>> space.add_observation(x, y) + >>> space.register(x, y) >>> len(space) 1 """ @@ -281,6 +309,11 @@ def register(self, params, target, constraint_value=None): raise NotUniqueError(f'Data point {x} is not unique. You can set' ' "allow_duplicate_points=True" to avoid this error') + # if x is not within the bounds of the parameter space, warn the user + if self._bounds is not None: + if not np.all((self._bounds[:, 0] <= x) & (x <= self._bounds[:, 1])): + warn(f'\nData point {x} is outside the bounds of the parameter space. ', stacklevel=2) + self._params = np.concatenate([self._params, x.reshape(1, -1)]) self._target = np.concatenate([self._target, [target]]) @@ -313,6 +346,15 @@ def probe(self, params): ------- y : float target function value. + + Example + ------- + >>> target_func = lambda p1, p2: p1 + p2 + >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} + >>> space = TargetSpace(target_func, pbounds) + >>> space.probe([1, 5]) + >>> assert self.max()['target'] == 6 + >>> assert self.max()['params'] == {'p1': 1.0, 'p2': 5.0} """ x = self._as_array(params) params = dict(zip(self._keys, x)) @@ -327,19 +369,20 @@ def probe(self, params): return target, constraint_value def random_sample(self): - """Create random points within the bounds of the space. + """ + Sample a random point from within the bounds of the space. Returns ------- - data: np.ndarray - [num x dim] array points with dimensions corresponding to `self._keys` + data: ndarray + [1 x dim] array with dimensions corresponding to `self._keys` Examples -------- >>> target_func = lambda p1, p2: p1 + p2 >>> pbounds = {'p1': (0, 1), 'p2': (1, 100)} >>> space = TargetSpace(target_func, pbounds, random_state=0) - >>> space.random_points(1) + >>> space.random_sample() array([[ 55.33253689, 0.54488318]]) """ data = np.empty((1, self.dim)) @@ -348,61 +391,48 @@ def random_sample(self): return data.ravel() def _target_max(self): - """Get maximum target value found. + """Get the maximum target value within the current parameter bounds. If there is a constraint present, the maximum value that fulfills the - constraint is returned. + constraint within the parameter bounds is returned. - Returns ------- - dict | None - The maximum allowed point's target function value. - Returns None if there is no (allowed) maximum. + max: float + The maximum target value. + """ if len(self.target) == 0: return None - if self._constraint is None: - return self.target.max() - - allowed = self._constraint.allowed(self._constraint_values) - if allowed.any(): - return self.target[allowed].max() + if len(self.target[self.mask]) == 0: + return None - return None + return self.target[self.mask].max() def max(self): """Get maximum target value found and corresponding parameters. - + If there is a constraint present, the maximum value that fulfills the - constraint is returned. + constraint within the parameter bounds is returned. Returns ------- - dict | None - A dictionary containing the maximum allowed point's target function - value, parameters, and, if applicable, constraint function value. - Returns None if there is no (allowed) maximum. + res: dict + A dictionary with the keys 'target' and 'params'. The value of + 'target' is the maximum target value, and the value of 'params' is + a dictionary with the parameter names as keys and the parameter + values as values. + """ target_max = self._target_max() - if target_max is None: return None - if self._constraint is not None: - allowed = self._constraint.allowed(self._constraint_values) - - target = self.target[allowed] - params = self.params[allowed] - constraint_values = self.constraint_values[allowed] - else: - target = self.target - params = self.params - - target_max_idx = np.where(target == target_max)[0][0] - - + target = self.target[self.mask] + params = self.params[self.mask] + target_max_idx = np.argmax(target) + res = { 'target': target_max, 'params': dict( @@ -411,6 +441,7 @@ def max(self): } if self._constraint is not None: + constraint_values = self.constraint_values[self.mask] res['constraint'] = constraint_values[target_max_idx] return res @@ -420,9 +451,17 @@ def res(self): Returns ------- - dict - A dictionary containing the target function values, parameters, - and, if applicable, constraint function values and allowedness. + res: list + A list of dictionaries with the keys 'target', 'params', and + 'constraint'. The value of 'target' is the target value, the value + of 'params' is a dictionary with the parameter names as keys and the + parameter values as values, and the value of 'constraint' is the + constraint fulfillment. + + Notes + ----- + Does not report if points are within the bounds of the parameter space. + """ if self._constraint is None: params = [dict(zip(self.keys, p)) for p in self.params] diff --git a/bayes_opt/util.py b/bayes_opt/util.py index 417e307f7..a90f344d7 100644 --- a/bayes_opt/util.py +++ b/bayes_opt/util.py @@ -8,7 +8,7 @@ def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000, n_iter=10, y_max_params=None): """Find the maximum of the acquisition function. - + It uses a combination of random sampling (cheap) and the 'L-BFGS-B' optimization method. First by sampling `n_warmup` (1e5) points at random, and then running L-BFGS-B from `n_iter` (10) random starting points. @@ -106,7 +106,6 @@ def adjusted_ac(x): x_seeds = random_state.uniform(bounds[:, 0], bounds[:, 1], size=(1+n_iter+int(not y_max_params is None), bounds.shape[0])) - x_seeds[0] = x_max if not y_max_params is None: # Add the provided best sample to the seeds so that the optimization diff --git a/docsrc/Makefile b/docsrc/Makefile index e0e46fb58..c3886de30 100644 --- a/docsrc/Makefile +++ b/docsrc/Makefile @@ -15,6 +15,8 @@ BUILDDIR = ../docs .PHONY: help Makefile github: + @cp ../README.md . + @cp -r ../static . @make html @cp -a ../docs/html/. ../docs diff --git a/docsrc/conf.py b/docsrc/conf.py index b758e36f4..159db2748 100644 --- a/docsrc/conf.py +++ b/docsrc/conf.py @@ -42,7 +42,9 @@ 'sphinx.ext.githubpages', 'nbsphinx', 'IPython.sphinxext.ipython_console_highlighting', - 'sphinx.ext.mathjax'] + 'sphinx.ext.mathjax', + 'myst_parser', + 'numpydoc'] source_suffix = { '.rst': 'restructuredtext', @@ -63,6 +65,7 @@ # a list of builtin themes. # html_theme = 'sphinx_rtd_theme' +html_favicon = 'func.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/docsrc/func.ico b/docsrc/func.ico new file mode 100644 index 0000000000000000000000000000000000000000..f294702610b6d5db3f5c55d0e2b71ea6ec497bc5 GIT binary patch literal 136207 zcmd3Lg;yMH%rB*d7B60;I19VzqQ#55yBBvaZY}P*xWnS^4#nNwi@4$I7GPru6J-`a5+(MaHenTU%&pBrv3B|?qf6@-1qPQmllG9 zV@i4l$ISe{bP+Wiochw6B-#I^Kf}SjzPy9`{Pz4$pZNzkxIzqgxKIT-aWrH?*!`|@1*A=5$>i32Gk4^ zpmGrS+x>{&jxM&cVUd|Bji9AOK5qf_2*5@#G*SbG*2PPQ9JfG6KA}{Of~o z(d*?ErL5~5m*;8i#IjX+`~323kz$@$Bq6)y|E~+OA{9_V-df0;iNs%p#9QCJnflFR z_QRiv!A#GSspo%r;;jVimTgobQ7-R&)&{R{mfH>dB`6H~k!XmI_hyUEbBiqC1St7# z*UWa))^`FYeAl}QGr55^mPuU1lg#+%_u!!1+jB^z=NCc#bX$JW#$rT;SQ(f9ad-!Qgpr z-I(jJ&sl5S@Tp7F$m^ewk%fDLMA)swj7Gk;ih$7;G((RC}&}j5IOx#+hD8l zew?y3jU*JnW`B34Jnea0KmYQ)k+xbZzTdnL)2Wv-wH^hZx&@zjo;W~9LW7-Dq z@>sdzcHw{aBTESj12}B!?kGtWhm1#CwvfH`@55B}pG(d?PpTin^;H;g0@6~Ux5x2B zgxt%r6>oC64QO}Dlh2zNhi<2yd`_zli9XvzEFUqDkJspC<_mIESUA8rhjG%x4^R8- zo!8}3OJz$*`fqX2&Fg=akbQqgN{f#ADNsl#Cx)xir@nW!*-%zis=VB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N6S=0gkWs}y4PZ$(@ z0>iNV7t2t|j8C=t&M?J+`CQ(gugqrTcLZ}poh45h!A!v}M*BUOE%1{Pm3vi_q*S|; znSdDPUIL{yV~I#+@AL1g(>RM#W5awggNT(MF#qxr@}xYB#{N`DV>U<~_b+4yr?FWjRG2{>+{1U}kNL5=)s%;XV3sA!r!WkJ5OHvEG6;3M(nQqi787qHDB} z9PLP?xS1KLMU2L8yLihFw&&-Vf|(HsBdYIm3u5a-zK+x^j2W6dW+aPbwXuTt6`^mJ z38$HhNM+uojJcyS?knTnW5wjWj`w3NAT-+uD*OlX;j5a!zKx z<`ks}5l=&`xEq+6HfUrilUT3DDB{al^G}6+*rNpFapoR&kc+4I86#zqK_?S=&(=`T z9gK8`@~ft4wDS8@beGJ9rZYEk5hd?>MQke-Syg~JgT{}bj%nrJ-}h5{Wgr(#`8B+I zhp80_z)a4jdFaI$=cn~X+0)GNouj~P6UVsj8SVwTPMCpa-pcII4+q25_dXqId6qGx- zIk7e?>!+^c_MZ=iloTo8`&Ei+^sXcv*eXURYhD$6>gVq+InCP5OB{*%(DQwnfO)Jt zbi|i*|JnPM8u|rAPQ0w}fGFActsx!oe+M&x+m?RF5Ym`?+544xPchbQlVXMSL5*fo zmp@4wBZrFdOi!s)-&Y>e4SWh5@f8nH5B*S(kB4IV4`je3?^SC(){dav>xrnY=r5 zJ865%T%~|_g~qdT=e)ynaScfWzEi4(br$I&U*MB8{Ky^DvGS>s5|$c8TxsJc6@Q=p z#e6h0qt<&_cFKJ3FNL#ZEL*&!n|bki{{XE71^-0f^x{Q7+y-;_UChs~53aA*e|LQ8 aZ global_bounds[i, 1]): + test = False + if (pbounds[1] > global_bounds[i, 1] or pbounds[1] < global_bounds[i, 0]): + test = False + return test + + # test if the sorting of the bounds is correct + new_bounds = np.array( [[5, -5], [-10, 10]] ) + trimmed_bounds = bounds_transformer._trim(new_bounds, global_bounds) + assert (trimmed_bounds == np.array( [[-5, 5], [-10, 10]] )).all() + + # test if both (upper/lower) bounds for a parameter exceed the global bounds + new_bounds = np.array( [[-50, -20], [20, 50]] ) + with pytest.warns(UserWarning): + trimmed_bounds = bounds_transformer._trim(new_bounds, global_bounds) + assert verify_bounds_in_range(trimmed_bounds, global_bounds) + + # test if both (upper/lower) bounds for a parameter exceed the global bounds + # while they are out of order + new_bounds = np.array( [[-20, -50], [-10, 10]] ) + with pytest.warns(UserWarning): + trimmed_bounds = bounds_transformer._trim(new_bounds, global_bounds) + assert verify_bounds_in_range(trimmed_bounds, global_bounds) + +if __name__ == '__main__': + r""" + CommandLine: + python tests/test_seq_domain_red.py + """ + pytest.main([__file__]) \ No newline at end of file diff --git a/tests/test_target_space.py b/tests/test_target_space.py index c554dea0e..494b42495 100644 --- a/tests/test_target_space.py +++ b/tests/test_target_space.py @@ -74,6 +74,7 @@ def test_as_array(): def test_register(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} space = TargetSpace(target_func, PBOUNDS) assert len(space) == 0 @@ -96,6 +97,7 @@ def test_register(): def test_register_with_constraint(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} constraint = ConstraintModel(lambda x: x, -2, 2) space = TargetSpace(target_func, PBOUNDS, constraint=constraint) @@ -118,7 +120,16 @@ def test_register_with_constraint(): space.register(params={"p1": 2, "p2": 2}, target=3) +def test_register_point_beyond_bounds(): + PBOUNDS = {'p1': (0, 1), 'p2': (1, 10)} + space = TargetSpace(target_func, PBOUNDS) + + with pytest.warns(UserWarning): + space.register(params={"p1": 0.5, "p2": 20}, target=2.5) + + def test_probe(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} space = TargetSpace(target_func, PBOUNDS, allow_duplicate_points=True) assert len(space) == 0 @@ -166,12 +177,14 @@ def test_random_sample(): def test_y_max(): space = TargetSpace(target_func, PBOUNDS) assert space._target_max() == None - space.probe(params={"p1": 1, "p2": 2}) - space.probe(params={"p1": 5, "p2": 1}) + space.probe(params={"p1": 1, "p2": 7}) + space.probe(params={"p1": 0.5, "p2": 1}) space.probe(params={"p1": 0, "p2": 1}) - assert space._target_max() == 6 + assert space._target_max() == 8 + def test_y_max_with_constraint(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} constraint = ConstraintModel(lambda p1, p2: p1-p2, -2, 2) space = TargetSpace(target_func, PBOUNDS, constraint) assert space._target_max() == None @@ -181,10 +194,21 @@ def test_y_max_with_constraint(): assert space._target_max() == 3 +def test_y_max_within_pbounds(): + PBOUNDS = {'p1': (0, 2), 'p2': (1, 100)} + space = TargetSpace(target_func, PBOUNDS) + assert space._target_max() == None + space.probe(params={"p1": 1, "p2": 2}) + space.probe(params={"p1": 0, "p2": 1}) + with pytest.warns(UserWarning): + space.probe(params={"p1": 5, "p2": 1}) + assert space._target_max() == 3 + def test_max(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} space = TargetSpace(target_func, PBOUNDS) - + assert space.max() == None space.probe(params={"p1": 1, "p2": 2}) space.probe(params={"p1": 5, "p2": 4}) @@ -192,7 +216,9 @@ def test_max(): space.probe(params={"p1": 1, "p2": 6}) assert space.max() == {"params": {"p1": 5, "p2": 4}, "target": 9} + def test_max_with_constraint(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} constraint = ConstraintModel(lambda p1, p2: p1-p2, -2, 2) space = TargetSpace(target_func, PBOUNDS, constraint=constraint) @@ -203,7 +229,9 @@ def test_max_with_constraint(): space.probe(params={"p1": 1, "p2": 6}) # Unfeasible assert space.max() == {"params": {"p1": 2, "p2": 3}, "target": 5, "constraint": -1} + def test_max_with_constraint_identical_target_value(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} constraint = ConstraintModel(lambda p1, p2: p1-p2, -2, 2) space = TargetSpace(target_func, PBOUNDS, constraint=constraint) @@ -215,7 +243,9 @@ def test_max_with_constraint_identical_target_value(): space.probe(params={"p1": 1, "p2": 6}) # Unfeasible assert space.max() == {"params": {"p1": 2, "p2": 3}, "target": 5, "constraint": -1} + def test_res(): + PBOUNDS = {'p1': (0, 10), 'p2': (1, 100)} space = TargetSpace(target_func, PBOUNDS) assert space.res() == [] diff --git a/tests/test_util.py b/tests/test_util.py index b3a73668a..89b79c01e 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -132,7 +132,7 @@ def f(x, y): optimizer = BayesianOptimization( f=f, - pbounds={"x": (-2, 2), "y": (-2, 2)} + pbounds={"x": (-200, 200), "y": (-200, 200)} ) assert len(optimizer.space) == 0 @@ -150,6 +150,21 @@ def f(x, y): load_logs(other_optimizer, [str(test_dir / "test_logs.log")]) +def test_logs_bounds(): + def f(x, y): + return x + y + + optimizer = BayesianOptimization( + f=f, + pbounds={"x": (-2, 2), "y": (-2, 2)} + ) + + with pytest.warns(UserWarning): + load_logs(optimizer, [str(test_dir / "test_logs_bounds.log")]) + + assert len(optimizer.space) == 5 + + def test_logs_constraint(): def f(x, y): @@ -162,7 +177,7 @@ def c(x, y): optimizer = BayesianOptimization( f=f, - pbounds={"x": (-2, 2), "y": (-2, 2)}, + pbounds={"x": (-200, 200), "y": (-200, 200)}, constraint=constraint ) @@ -179,5 +194,4 @@ def c(x, y): CommandLine: python tests/test_target_space.py """ - import pytest - pytest.main([__file__]) + pytest.main([__file__]) \ No newline at end of file From 8ffdb4ff8956ccc280a090f95fabb2bea9b908b5 Mon Sep 17 00:00:00 2001 From: till-m Date: Wed, 31 Jan 2024 22:24:31 +0100 Subject: [PATCH 06/13] Small fixes, minor cosmetic changes --- bayes_opt/constraint.py | 6 +++--- bayes_opt/domain_reduction.py | 12 ++++++------ bayes_opt/target_space.py | 35 ++++++----------------------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index 10142e43b..bf722fc25 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -6,7 +6,7 @@ class ConstraintModel(): - """Model constraints using GPRs. + """Model constraints using GP regressors. This class takes the function to optimize as well as the parameters bounds in order to find which values for the parameters yield the maximum value @@ -65,7 +65,7 @@ def model(self): """Return GP regressors of the constraint function.""" return self._model - def eval(self, **kwargs): + def eval(self, **kwargs: dict): """Evaluate the constraint function. Parameters @@ -206,7 +206,7 @@ def allowed(self, constraint_values): Returns ------- - np.ndarrray of shape (n_samples,) + np.ndarrray of shape (n_samples,) Specifying wheter the constraints are fulfilled. """ diff --git a/bayes_opt/domain_reduction.py b/bayes_opt/domain_reduction.py index b4ce4811c..0d5098909 100644 --- a/bayes_opt/domain_reduction.py +++ b/bayes_opt/domain_reduction.py @@ -117,21 +117,21 @@ def _update(self, target_space: TargetSpace) -> None: self.r = self.contraction_rate * self.r - def _trim(self, new_bounds: np.array, global_bounds: np.array) -> np.array: + def _trim(self, new_bounds: np.ndarray, global_bounds: np.ndarray) -> np.ndarray: """ Adjust the new_bounds and verify that they adhere to global_bounds and minimum_window. Parameters ---------- - new_bounds : np.array + new_bounds : np.ndarray The proposed new_bounds that (may) need adjustment. - global_bounds : np.array + global_bounds : np.ndarray The maximum allowable bounds for each parameter. Returns ------- - new_bounds : np.array + new_bounds : np.ndarray The adjusted bounds after enforcing constraints. """ #sort bounds @@ -192,7 +192,7 @@ def _trim(self, new_bounds: np.array, global_bounds: np.array) -> np.array: return new_bounds - def _window_bounds_compatibility(self, global_bounds: np.array) -> bool: + def _window_bounds_compatibility(self, global_bounds: np.ndarray) -> bool: """Check if global bounds are compatible with the minimum window sizes.""" for i, entry in enumerate(global_bounds): global_window_width = abs(entry[1] - entry[0]) @@ -200,7 +200,7 @@ def _window_bounds_compatibility(self, global_bounds: np.array) -> bool: raise ValueError( "Global bounds are not compatible with the minimum window size.") - def _create_bounds(self, parameters: dict, bounds: np.array) -> dict: + def _create_bounds(self, parameters: dict, bounds: np.ndarray) -> dict: return {param: bounds[i, :] for i, param in enumerate(parameters)} def transform(self, target_space: TargetSpace) -> dict: diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 4a1a30181..54894c21f 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -205,22 +205,6 @@ def mask(self): return mask - @property - def mask(self): - '''Returns a boolean array of the points that satisfy the constraint and boundary conditions''' - mask = np.ones_like(self.target, dtype=bool) - - # mask points that don't satisfy the constraint - if self._constraint is not None: - mask &= self._constraint.allowed(self._constraint_values) - - # mask points that are outside the bounds - if self._bounds is not None: - within_bounds = np.all((self._bounds[:, 0] <= self._params) & - (self._params <= self._bounds[:, 1]), axis=1) - mask &= within_bounds - - return mask def params_to_array(self, params): """Convert a dict representation of parameters into an array version. @@ -235,13 +219,11 @@ def params_to_array(self, params): np.ndarray Representation of the parameters as dictionary. """ - try: - assert set(params) == set(self.keys) - except AssertionError as e: + if not set(params) == set(self.keys): raise ValueError( f"Parameters' keys ({sorted(params)}) do " + f"not match the expected set of keys ({self.keys})." - ) from e + ) return np.asarray([params[key] for key in self.keys]) def array_to_params(self, x): @@ -257,13 +239,11 @@ def array_to_params(self, x): dict Representation of the parameters as dictionary. """ - try: - assert len(x) == len(self.keys) - except AssertionError as e: + if not len(x) == len(self.keys): raise ValueError( f"Size of array ({len(x)}) is different than the " + f"expected number of parameters ({len(self.keys)})." - ) from e + ) return dict(zip(self.keys, x)) def _as_array(self, x): @@ -273,13 +253,11 @@ def _as_array(self, x): x = self.params_to_array(x) x = x.ravel() - try: - assert x.size == self.dim - except AssertionError as e: + if not x.size == self.dim: raise ValueError( f"Size of array ({len(x)}) is different than the " + f"expected number of parameters ({len(self.keys)})." - ) from e + ) return x def register(self, params, target, constraint_value=None): @@ -485,7 +463,6 @@ def res(self): Does not report if points are within the bounds of the parameter space. """ - if self._constraint is None: params = [dict(zip(self.keys, p)) for p in self.params] From 9dfffb75e80856de03050b6f78189cf827a98380 Mon Sep 17 00:00:00 2001 From: till-m Date: Thu, 1 Feb 2024 17:48:23 +0100 Subject: [PATCH 07/13] Add some more docs to target space and constraint, cosmetic changes --- bayes_opt/constraint.py | 7 +++++ bayes_opt/domain_reduction.py | 57 ++++++++++++++++++++++++++++++++--- bayes_opt/target_space.py | 3 -- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index bf722fc25..0c8c3c843 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -29,6 +29,13 @@ class ConstraintModel(): random_state : np.random.RandomState or int or None, default=None Random state to use. + + Notes + ----- + In case of multiple constraints, this model assumes conditional + independence. This means that for each constraint, the probability of + fulfillment is the cdf of a univariate Gaussian. The overall probability + is a simply the product of the individual probabilities. """ def __init__(self, fun, lb, ub, random_state=None): diff --git a/bayes_opt/domain_reduction.py b/bayes_opt/domain_reduction.py index 0d5098909..09ae868e9 100644 --- a/bayes_opt/domain_reduction.py +++ b/bayes_opt/domain_reduction.py @@ -32,6 +32,20 @@ class SequentialDomainReductionTransformer(DomainTransformer): A sequential domain reduction transformer based on the work by Stander, N. and Craig, K: "On the robustness of a simple domain reduction scheme for simulation-based optimization" + + Parameters + ---------- + gamma_osc : float, default=0.7 + Parameter used to scale (typically dampen) oscillations. + + gamma_pan : float, default=1.0 + Parameter used to scale (typically unitary) panning. + + eta : float, default=0.9 + Zooming parameter used to shrink the region of interest. + + minimum_window : float or np.ndarray or dict, default=0.0 + Minimum window size for each parameter. If a float is provided, the same value is used for all parameters. """ def __init__( @@ -95,7 +109,13 @@ def initialize(self, target_space: TargetSpace) -> None: self._window_bounds_compatibility(self.original_bounds) def _update(self, target_space: TargetSpace) -> None: - """Update contraction rate, window size, and window center.""" + """Update contraction rate, window size, and window center. + + Parameters + ---------- + target_space : TargetSpace + TargetSpace this DomainTransformer operates on. + """ # setting the previous self.previous_optimal = self.current_optimal self.previous_d = self.current_d @@ -192,8 +212,19 @@ def _trim(self, new_bounds: np.ndarray, global_bounds: np.ndarray) -> np.ndarray return new_bounds - def _window_bounds_compatibility(self, global_bounds: np.ndarray) -> bool: - """Check if global bounds are compatible with the minimum window sizes.""" + def _window_bounds_compatibility(self, global_bounds: np.ndarray): + """Check if global bounds are compatible with the minimum window sizes. + + Parameters + ---------- + global_bounds : np.ndarray + The maximum allowable bounds for each parameter. + + Raises + ------ + ValueError + If global bounds are not compatible with the minimum window size. + """ for i, entry in enumerate(global_bounds): global_window_width = abs(entry[1] - entry[0]) if global_window_width < self.minimum_window[i]: @@ -201,10 +232,28 @@ def _window_bounds_compatibility(self, global_bounds: np.ndarray) -> bool: "Global bounds are not compatible with the minimum window size.") def _create_bounds(self, parameters: dict, bounds: np.ndarray) -> dict: + """Create a dictionary of bounds for each parameter. + + Parameters + ---------- + parameters : dict + The parameters for which to create the bounds. + """ return {param: bounds[i, :] for i, param in enumerate(parameters)} def transform(self, target_space: TargetSpace) -> dict: - """Transform the bounds of the target space.""" + """Transform the bounds of the target space. + + Parameters + ---------- + target_space : TargetSpace + TargetSpace this DomainTransformer operates on. + + Returns + ------- + dict + The new bounds of each parameter. + """ self._update(target_space) new_bounds = np.array( diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 54894c21f..cde049c3d 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -400,7 +400,6 @@ def _target_max(self): ------- max: float The maximum target value. - """ if len(self.target) == 0: return None @@ -423,7 +422,6 @@ def max(self): 'target' is the maximum target value, and the value of 'params' is a dictionary with the parameter names as keys and the parameter values as values. - """ target_max = self._target_max() if target_max is None: @@ -461,7 +459,6 @@ def res(self): Notes ----- Does not report if points are within the bounds of the parameter space. - """ if self._constraint is None: params = [dict(zip(self.keys, p)) for p in self.params] From cb7e40698d7113d37b1e65262d48d1c10b537279 Mon Sep 17 00:00:00 2001 From: till-m Date: Thu, 1 Feb 2024 21:39:00 +0100 Subject: [PATCH 08/13] Remove duplicate code snippet --- bayes_opt/target_space.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index cde049c3d..0012e29e8 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -309,11 +309,6 @@ def register(self, params, target, constraint_value=None): if not np.all((self._bounds[:, 0] <= x) & (x <= self._bounds[:, 1])): warn(f'\nData point {x} is outside the bounds of the parameter space. ', stacklevel=2) - # if x is not within the bounds of the parameter space, warn the user - if self._bounds is not None: - if not np.all((self._bounds[:, 0] <= x) & (x <= self._bounds[:, 1])): - warn(f'\nData point {x} is outside the bounds of the parameter space. ', stacklevel=2) - self._params = np.concatenate([self._params, x.reshape(1, -1)]) self._target = np.concatenate([self._target, [target]]) From cbf6c24b04f44f31e727b25eea26c282f011ffd3 Mon Sep 17 00:00:00 2001 From: till-m Date: Wed, 7 Feb 2024 10:21:17 +0100 Subject: [PATCH 09/13] Remove numpydoc + adjust "*" formatting accordingly --- .github/workflows/build_docs.yml | 1 - bayes_opt/constraint.py | 4 ++-- docsrc/conf.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index a57745b01..d461c2dab 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -29,7 +29,6 @@ jobs: pip install nbsphinx pip install sphinx_rtd_theme pip install jupyter - pip install numpydoc pip install myst-parser - name: Install package run: | diff --git a/bayes_opt/constraint.py b/bayes_opt/constraint.py index 0c8c3c843..ec15d998c 100644 --- a/bayes_opt/constraint.py +++ b/bayes_opt/constraint.py @@ -73,11 +73,11 @@ def model(self): return self._model def eval(self, **kwargs: dict): - """Evaluate the constraint function. + r"""Evaluate the constraint function. Parameters ---------- - **kwargs : + \*\*kwargs : Function arguments to evaluate the constraint function on. diff --git a/docsrc/conf.py b/docsrc/conf.py index 159db2748..9393cec85 100644 --- a/docsrc/conf.py +++ b/docsrc/conf.py @@ -43,8 +43,8 @@ 'nbsphinx', 'IPython.sphinxext.ipython_console_highlighting', 'sphinx.ext.mathjax', - 'myst_parser', - 'numpydoc'] + 'myst_parser' +] source_suffix = { '.rst': 'restructuredtext', From 8a0265cfc5640d97bdda483a53039b57932d59cc Mon Sep 17 00:00:00 2001 From: till-m Date: Wed, 7 Feb 2024 16:11:46 +0100 Subject: [PATCH 10/13] Explicitly add D417, adjust code accordingly --- .github/workflows/check_docstrings.yml | 2 +- bayes_opt/bayesian_optimization.py | 21 ++++++++++++++++++--- bayes_opt/domain_reduction.py | 3 +++ bayes_opt/logger.py | 23 ++++++++++++----------- bayes_opt/target_space.py | 9 ++++++--- bayes_opt/util.py | 2 ++ 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check_docstrings.yml b/.github/workflows/check_docstrings.yml index 4f6e8ce94..83b5d4ac8 100644 --- a/.github/workflows/check_docstrings.yml +++ b/.github/workflows/check_docstrings.yml @@ -25,6 +25,6 @@ jobs: python -m pip install --upgrade pip pip install pydocstyle - name: Check docstyle - run : pydocstyle --convention=numpy bayes_opt/* + run : pydocstyle --convention=numpy --add-select D417 bayes_opt/* #- name: Run linting # run : pylint bayes_opt/* --disable=C0103 # ignore no snake_case conformity of arguments diff --git a/bayes_opt/bayesian_optimization.py b/bayes_opt/bayesian_optimization.py index 3c20eab6d..fe09f65a5 100644 --- a/bayes_opt/bayesian_optimization.py +++ b/bayes_opt/bayesian_optimization.py @@ -308,7 +308,7 @@ def maximize(self, kappa_decay_delay=None, xi=None, **gp_params): - """ + r""" Maximize the given function over the target space. Parameters @@ -325,8 +325,23 @@ def maximize(self, An instance of bayes_opt.util.UtilityFunction. If nothing is passed, a default using ucb is used - All other parameters are unused, and are only available to ensure backwards compatibility - these - will be removed in a future release + acq: + Deprecated, unused and slated for deletion. + + kappa: + Deprecated, unused and slated for deletion. + + kappa_decay: + Deprecated, unused and slated for deletion. + + kappa_decay_delay: + Deprecated, unused and slated for deletion. + + xi: + Deprecated, unused and slated for deletion. + + \*\*gp_params: + Deprecated, unused and slated for deletion. """ self._prime_subscriptions() self.dispatch(Events.OPTIMIZATION_START) diff --git a/bayes_opt/domain_reduction.py b/bayes_opt/domain_reduction.py index 09ae868e9..d48a70d7a 100644 --- a/bayes_opt/domain_reduction.py +++ b/bayes_opt/domain_reduction.py @@ -238,6 +238,9 @@ def _create_bounds(self, parameters: dict, bounds: np.ndarray) -> dict: ---------- parameters : dict The parameters for which to create the bounds. + + bounds : np.ndarray + The bounds for each parameter. """ return {param: bounds[i, :] for i, param in enumerate(parameters)} diff --git a/bayes_opt/logger.py b/bayes_opt/logger.py index 273087e9f..84182c184 100644 --- a/bayes_opt/logger.py +++ b/bayes_opt/logger.py @@ -79,7 +79,7 @@ def _format_number(self, x): Parameters ---------- x : number - + Value to format. Returns ------- @@ -102,7 +102,7 @@ def _format_bool(self, x): Parameters ---------- x : boolean - + Value to format. Returns ------- @@ -124,7 +124,7 @@ def _format_key(self, key): Parameters ---------- key : string - + Value to format. Returns ------- @@ -245,17 +245,18 @@ class JSONLogger(_Tracker): Logger that outputs steps in JSON format. The resulting file can be used to restart the optimization from an earlier state. + + Parameters + ---------- + path : str or bytes or os.PathLike + Path to the file to write to. + + reset : bool + Whether to overwrite the file if it already exists. + """ def __init__(self, path, reset=True): - """ - Initialize the logger. - - Parameters - ---------- - path : str or bytes or os.PathLike - - """ self._path = path if reset: try: diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 0012e29e8..04e3f5873 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -265,15 +265,18 @@ def register(self, params, target, constraint_value=None): Parameters ---------- - x : np.ndarray + params : np.ndarray a single point, with len(x) == self.dim. - y : float + target : float target function value + constraint_value : float or None + Constraint function value + Raises ------ - KeyError: + NotUniqueError: if the point is not unique Notes diff --git a/bayes_opt/util.py b/bayes_opt/util.py index ed1ff0eca..9a2a82ea4 100644 --- a/bayes_opt/util.py +++ b/bayes_opt/util.py @@ -36,6 +36,8 @@ def acq_max(ac, gp, y_max, bounds, random_state, constraint=None, n_warmup=10000 A random state to sample from. constraint : ConstraintModel or None, default=None + If provided, the acquisition function will be adjusted according + to the probability of fulfilling the constraint. n_warmup : int, default=10000 Number of points to sample from the acquisition function as seeds From 170e84c30984016b2ff5d7ee48879e5b85607195 Mon Sep 17 00:00:00 2001 From: till-m Date: Mon, 12 Feb 2024 10:26:02 +0100 Subject: [PATCH 11/13] Adjust `TargetSpace.probe()` behaviour to be in line with docstring. --- bayes_opt/target_space.py | 11 ++++++++--- tests/test_target_space.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 04e3f5873..792884c7a 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -333,7 +333,8 @@ def probe(self, params): Notes ----- - If `params` has been previously seen returns a cached value of `y`. + If `params` has been previously seen and duplicate points are not allowed, + returns a cached value of `result`. Parameters ---------- @@ -342,8 +343,8 @@ def probe(self, params): Returns ------- - y : float - target function value. + result : float | Tuple(float, float) + target function value, or Tuple(target function value, constraint value) Example ------- @@ -355,6 +356,10 @@ def probe(self, params): >>> assert self.max()['params'] == {'p1': 1.0, 'p2': 5.0} """ x = self._as_array(params) + if x in self: + if not self._allow_duplicate_points: + return self._cache[_hashable(x.ravel())] + params = dict(zip(self._keys, x)) target = self.target_func(**params) diff --git a/tests/test_target_space.py b/tests/test_target_space.py index 494b42495..d009cbc48 100644 --- a/tests/test_target_space.py +++ b/tests/test_target_space.py @@ -157,6 +157,19 @@ def test_probe(): assert all(space.params[1] == np.array([5, 4])) assert all(space.target == np.array([3, 9, 3 , 9])) + space = TargetSpace(target_func, PBOUNDS, allow_duplicate_points=False) + + # register wrong target to check probe doesn't recompute a duplicate point + space.register(params={"p1": 1, "p2": 2}, target=5) + + # probing same point with dict + target_ = space.probe(params={"p1": 1, "p2": 2}) + assert target_ == 5 + + # probing same point with array + target_ = space.probe(np.array([1, 2])) + assert target_ == 5 + def test_random_sample(): pbounds = { From 58abfb6349308ed79a71747d58d778b24ee22f6c Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:23:10 +0100 Subject: [PATCH 12/13] Update bayes_opt/target_space.py Co-authored-by: Edgar <50716923+perezed00@users.noreply.github.com> --- bayes_opt/target_space.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bayes_opt/target_space.py b/bayes_opt/target_space.py index 792884c7a..89f523dfc 100644 --- a/bayes_opt/target_space.py +++ b/bayes_opt/target_space.py @@ -217,7 +217,7 @@ def params_to_array(self, params): Returns ------- np.ndarray - Representation of the parameters as dictionary. + Representation of the parameters as an array. """ if not set(params) == set(self.keys): raise ValueError( From 17f1e27637faffe559252eabf62858c44d93dc03 Mon Sep 17 00:00:00 2001 From: till-m <36440677+till-m@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:43:58 +0100 Subject: [PATCH 13/13] Update README.md --- README.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/README.md b/README.md index 652dc9a18..229fa2ef2 100644 --- a/README.md +++ b/README.md @@ -273,21 +273,6 @@ load_logs(new_optimizer, logs=["./logs.log"]); This introduction covered the most basic functionality of the package. Checkout the [basic-tour](http://bayesian-optimization.github.io/BayesianOptimization/basic-tour.html) and [advanced-tour](http://bayesian-optimization.github.io/BayesianOptimization/advanced-tour.html), where you will find detailed explanations and other more advanced functionality. Also, browse the [examples](http://bayesian-optimization.github.io/BayesianOptimization/examples.html) for implementation tips and ideas. -## Installing from GitHub -To install directly from master, simply run -``` -pip install https://github.com/bayesian-optimization/BayesianOptimization/archive/master.zip -``` -Please note that these builds are not necessarily stable. - -If you prefer, you can also clone the repository and run `setup.py`: -``` -git clone https://github.com/bayesian-optimization/BayesianOptimization.git -cd BayesianOptimization -python setup.py install -``` - - ## Minutiae ### Citation @@ -330,11 +315,6 @@ For constrained optimization: } ``` -### Dependencies -* Numpy -* Scipy -* Scikit-learn - ### References: * http://papers.nips.cc/paper/4522-practical-bayesian-optimization-of-machine-learning-algorithms.pdf * http://arxiv.org/pdf/1012.2599v1.pdf