bayesian-optimization 3.2.0__tar.gz → 3.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bayesian-optimization
3
- Version: 3.2.0
3
+ Version: 3.2.1
4
4
  Summary: Bayesian Optimization package
5
5
  Author: Fernando Nogueira
6
6
  Author-email: Fernando Nogueira <fmfnogueira@gmail.com>
@@ -99,13 +99,13 @@ class AcquisitionFunction(abc.ABC):
99
99
  )
100
100
  raise NotImplementedError(error_msg)
101
101
 
102
- def set_acquisition_params(self, **params) -> None:
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
- **params : dict
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
@@ -328,7 +328,7 @@ class BayesianOptimization:
328
328
  self._space.keys, self._space.res()[-1], self._space.params_config, self.max
329
329
  )
330
330
 
331
- def random_sample(self, n: int = 1) -> dict[str, float | NDArray[Float]]:
331
+ def random_sample(self, n: int = 1) -> list[dict[str, float | NDArray[Float]]]:
332
332
  """Generate a random sample of parameters from the target space.
333
333
 
334
334
  Parameters
@@ -442,13 +442,13 @@ class BayesianOptimization:
442
442
  """
443
443
  random_state = None
444
444
  if self._random_state is not None:
445
- state_tuple = self._random_state.get_state()
445
+ state_dict = self._random_state.get_state(legacy=False)
446
446
  random_state = {
447
- "bit_generator": state_tuple[0],
448
- "state": state_tuple[1].tolist(),
449
- "pos": state_tuple[2],
450
- "has_gauss": state_tuple[3],
451
- "cached_gaussian": state_tuple[4],
447
+ "bit_generator": state_dict["bit_generator"],
448
+ "state": state_dict["state"]["key"].tolist(),
449
+ "pos": state_dict["state"]["pos"],
450
+ "has_gauss": state_dict["has_gauss"],
451
+ "cached_gaussian": state_dict["gauss"],
452
452
  }
453
453
 
454
454
  # 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": dict(zip(self.keys, params[target_max_idx]))}
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 = [dict(zip(self.keys, p)) for p in self.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}
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bayesian-optimization"
3
- version = "3.2.0"
3
+ version = "3.2.1"
4
4
  description = "Bayesian Optimization package"
5
5
  authors = [{ name = "Fernando Nogueira", email = "fmfnogueira@gmail.com" }]
6
6
  license = { file = "LICENSE" }