bayesian-optimization 3.2.0__tar.gz → 3.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/PKG-INFO +1 -1
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/acquisition.py +12 -12
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/bayesian_optimization.py +7 -33
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/target_space.py +2 -2
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/pyproject.toml +1 -1
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/LICENSE +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/README.md +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/__init__.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/constraint.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/domain_reduction.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/exception.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/logger.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/parameter.py +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/py.typed +0 -0
- {bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/util.py +0 -0
|
@@ -99,13 +99,13 @@ class AcquisitionFunction(abc.ABC):
|
|
|
99
99
|
)
|
|
100
100
|
raise NotImplementedError(error_msg)
|
|
101
101
|
|
|
102
|
-
def set_acquisition_params(self,
|
|
102
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
103
103
|
"""
|
|
104
104
|
Set the parameters of the acquisition function.
|
|
105
105
|
|
|
106
106
|
Parameters
|
|
107
107
|
----------
|
|
108
|
-
|
|
108
|
+
params : dict
|
|
109
109
|
The parameters of the acquisition function.
|
|
110
110
|
"""
|
|
111
111
|
error_msg = (
|
|
@@ -553,7 +553,7 @@ class UpperConfidenceBound(AcquisitionFunction):
|
|
|
553
553
|
):
|
|
554
554
|
self.kappa = self.kappa * self.exploration_decay
|
|
555
555
|
|
|
556
|
-
def get_acquisition_params(self) -> dict:
|
|
556
|
+
def get_acquisition_params(self) -> dict[str, Any]:
|
|
557
557
|
"""Get the current acquisition function parameters.
|
|
558
558
|
|
|
559
559
|
Returns
|
|
@@ -567,7 +567,7 @@ class UpperConfidenceBound(AcquisitionFunction):
|
|
|
567
567
|
"exploration_decay_delay": self.exploration_decay_delay,
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
def set_acquisition_params(self, params: dict) -> None:
|
|
570
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
571
571
|
"""Set the acquisition function parameters.
|
|
572
572
|
|
|
573
573
|
Parameters
|
|
@@ -733,7 +733,7 @@ class ProbabilityOfImprovement(AcquisitionFunction):
|
|
|
733
733
|
):
|
|
734
734
|
self.xi = self.xi * self.exploration_decay
|
|
735
735
|
|
|
736
|
-
def get_acquisition_params(self) -> dict:
|
|
736
|
+
def get_acquisition_params(self) -> dict[str, Any]:
|
|
737
737
|
"""Get the current acquisition function parameters.
|
|
738
738
|
|
|
739
739
|
Returns
|
|
@@ -747,7 +747,7 @@ class ProbabilityOfImprovement(AcquisitionFunction):
|
|
|
747
747
|
"exploration_decay_delay": self.exploration_decay_delay,
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
def set_acquisition_params(self, params: dict) -> None:
|
|
750
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
751
751
|
"""Set the acquisition function parameters.
|
|
752
752
|
|
|
753
753
|
Parameters
|
|
@@ -922,7 +922,7 @@ class ExpectedImprovement(AcquisitionFunction):
|
|
|
922
922
|
):
|
|
923
923
|
self.xi = self.xi * self.exploration_decay
|
|
924
924
|
|
|
925
|
-
def get_acquisition_params(self) -> dict:
|
|
925
|
+
def get_acquisition_params(self) -> dict[str, Any]:
|
|
926
926
|
"""Get the current acquisition function parameters.
|
|
927
927
|
|
|
928
928
|
Returns
|
|
@@ -936,7 +936,7 @@ class ExpectedImprovement(AcquisitionFunction):
|
|
|
936
936
|
"exploration_decay_delay": self.exploration_decay_delay,
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
-
def set_acquisition_params(self, params: dict) -> None:
|
|
939
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
940
940
|
"""Set the acquisition function parameters.
|
|
941
941
|
|
|
942
942
|
Parameters
|
|
@@ -1147,7 +1147,7 @@ class ConstantLiar(AcquisitionFunction):
|
|
|
1147
1147
|
|
|
1148
1148
|
return x_max
|
|
1149
1149
|
|
|
1150
|
-
def get_acquisition_params(self) -> dict:
|
|
1150
|
+
def get_acquisition_params(self) -> dict[str, Any]:
|
|
1151
1151
|
"""Get the current acquisition function parameters.
|
|
1152
1152
|
|
|
1153
1153
|
Returns
|
|
@@ -1163,7 +1163,7 @@ class ConstantLiar(AcquisitionFunction):
|
|
|
1163
1163
|
"rtol": self.rtol,
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
|
-
def set_acquisition_params(self, params: dict) -> None:
|
|
1166
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
1167
1167
|
"""Set the acquisition function parameters.
|
|
1168
1168
|
|
|
1169
1169
|
Parameters
|
|
@@ -1318,7 +1318,7 @@ class GPHedge(AcquisitionFunction):
|
|
|
1318
1318
|
idx = self._sample_idx_from_softmax_gains(random_state=random_state)
|
|
1319
1319
|
return x_max[idx]
|
|
1320
1320
|
|
|
1321
|
-
def get_acquisition_params(self) -> dict:
|
|
1321
|
+
def get_acquisition_params(self) -> dict[str, Any]:
|
|
1322
1322
|
"""Get the current acquisition function parameters.
|
|
1323
1323
|
|
|
1324
1324
|
Returns
|
|
@@ -1334,7 +1334,7 @@ class GPHedge(AcquisitionFunction):
|
|
|
1334
1334
|
else None,
|
|
1335
1335
|
}
|
|
1336
1336
|
|
|
1337
|
-
def set_acquisition_params(self, params: dict) -> None:
|
|
1337
|
+
def set_acquisition_params(self, params: dict[str, Any]) -> None:
|
|
1338
1338
|
"""Set the acquisition function parameters.
|
|
1339
1339
|
|
|
1340
1340
|
Parameters
|
{bayesian_optimization-3.2.0 → bayesian_optimization-3.2.2}/bayes_opt/bayesian_optimization.py
RENAMED
|
@@ -12,7 +12,6 @@ from collections.abc import Iterable
|
|
|
12
12
|
from os import PathLike
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
from typing import TYPE_CHECKING, Any
|
|
15
|
-
from warnings import warn
|
|
16
15
|
|
|
17
16
|
import numpy as np
|
|
18
17
|
from scipy.optimize import NonlinearConstraint
|
|
@@ -138,8 +137,6 @@ class BayesianOptimization:
|
|
|
138
137
|
raise TypeError(msg)
|
|
139
138
|
self._bounds_transformer.initialize(self._space)
|
|
140
139
|
|
|
141
|
-
self._sorting_warning_already_shown = False # TODO: remove in future version
|
|
142
|
-
|
|
143
140
|
# Initialize logger
|
|
144
141
|
self.logger = ScreenLogger(verbose=self._verbose, is_constrained=self.is_constrained)
|
|
145
142
|
|
|
@@ -278,17 +275,6 @@ class BayesianOptimization:
|
|
|
278
275
|
constraint_value: float or None
|
|
279
276
|
Value of the constraint function at the observation, if any.
|
|
280
277
|
"""
|
|
281
|
-
# TODO: remove in future version
|
|
282
|
-
if isinstance(params, np.ndarray) and not self._sorting_warning_already_shown:
|
|
283
|
-
msg = (
|
|
284
|
-
"You're attempting to register an np.ndarray. In previous versions, the optimizer internally"
|
|
285
|
-
" sorted parameters by key and expected any registered array to respect this order."
|
|
286
|
-
" In the current and any future version the order as given by the pbounds dictionary will be"
|
|
287
|
-
" used. If you wish to retain sorted parameters, please manually sort your pbounds"
|
|
288
|
-
" dictionary before constructing the optimizer."
|
|
289
|
-
)
|
|
290
|
-
warn(msg, stacklevel=1)
|
|
291
|
-
self._sorting_warning_already_shown = True
|
|
292
278
|
self._space.register(params, target, constraint_value)
|
|
293
279
|
self.logger.log_optimization_step(
|
|
294
280
|
self._space.keys, self._space.res()[-1], self._space.params_config, self.max
|
|
@@ -308,18 +294,6 @@ class BayesianOptimization:
|
|
|
308
294
|
If True, the optimizer will evaluate the points when calling
|
|
309
295
|
maximize(). Otherwise it will evaluate it at the moment.
|
|
310
296
|
"""
|
|
311
|
-
# TODO: remove in future version
|
|
312
|
-
if isinstance(params, np.ndarray) and not self._sorting_warning_already_shown:
|
|
313
|
-
msg = (
|
|
314
|
-
"You're attempting to register an np.ndarray. In previous versions, the optimizer internally"
|
|
315
|
-
" sorted parameters by key and expected any registered array to respect this order."
|
|
316
|
-
" In the current and any future version the order as given by the pbounds dictionary will be"
|
|
317
|
-
" used. If you wish to retain sorted parameters, please manually sort your pbounds"
|
|
318
|
-
" dictionary before constructing the optimizer."
|
|
319
|
-
)
|
|
320
|
-
warn(msg, stacklevel=1)
|
|
321
|
-
self._sorting_warning_already_shown = True
|
|
322
|
-
params = self._space.array_to_params(params)
|
|
323
297
|
if lazy:
|
|
324
298
|
self._queue.append(params)
|
|
325
299
|
else:
|
|
@@ -328,7 +302,7 @@ class BayesianOptimization:
|
|
|
328
302
|
self._space.keys, self._space.res()[-1], self._space.params_config, self.max
|
|
329
303
|
)
|
|
330
304
|
|
|
331
|
-
def random_sample(self, n: int = 1) -> dict[str, float | NDArray[Float]]:
|
|
305
|
+
def random_sample(self, n: int = 1) -> list[dict[str, float | NDArray[Float]]]:
|
|
332
306
|
"""Generate a random sample of parameters from the target space.
|
|
333
307
|
|
|
334
308
|
Parameters
|
|
@@ -442,13 +416,13 @@ class BayesianOptimization:
|
|
|
442
416
|
"""
|
|
443
417
|
random_state = None
|
|
444
418
|
if self._random_state is not None:
|
|
445
|
-
|
|
419
|
+
state_dict = self._random_state.get_state(legacy=False)
|
|
446
420
|
random_state = {
|
|
447
|
-
"bit_generator":
|
|
448
|
-
"state":
|
|
449
|
-
"pos":
|
|
450
|
-
"has_gauss":
|
|
451
|
-
"cached_gaussian":
|
|
421
|
+
"bit_generator": state_dict["bit_generator"],
|
|
422
|
+
"state": state_dict["state"]["key"].tolist(),
|
|
423
|
+
"pos": state_dict["state"]["pos"],
|
|
424
|
+
"has_gauss": state_dict["has_gauss"],
|
|
425
|
+
"cached_gaussian": state_dict["gauss"],
|
|
452
426
|
}
|
|
453
427
|
|
|
454
428
|
# Get constraint values if they exist
|
|
@@ -643,7 +643,7 @@ class TargetSpace:
|
|
|
643
643
|
params = self.params[self.mask]
|
|
644
644
|
target_max_idx = np.argmax(target)
|
|
645
645
|
|
|
646
|
-
res = {"target": target_max, "params":
|
|
646
|
+
res = {"target": target_max, "params": self.array_to_params(params[target_max_idx])}
|
|
647
647
|
|
|
648
648
|
if self._constraint is not None:
|
|
649
649
|
constraint_values = self.constraint_values[self.mask]
|
|
@@ -672,7 +672,7 @@ class TargetSpace:
|
|
|
672
672
|
|
|
673
673
|
return [{"target": target, "params": param} for target, param in zip(self.target, params)]
|
|
674
674
|
|
|
675
|
-
params = [
|
|
675
|
+
params = [self.array_to_params(p) for p in self.params]
|
|
676
676
|
|
|
677
677
|
return [
|
|
678
678
|
{"target": target, "constraint": constraint_value, "params": param, "allowed": allowed}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|