MCPcopy Create free account
hub / github.com/bayesian-optimization/BayesianOptimization / max

Method max

bayes_opt/target_space.py:624–652  ·  view source on GitHub ↗

Get maximum target value found and corresponding parameters. If there is a constraint present, the maximum value that fulfills the constraint within the parameter bounds is returned. Returns ------- res: dict A dictionary with the keys 'target' a

(self)

Source from the content-addressed store, hash-verified

622 return self.target[self.mask].max()
623
624 def max(self) -> dict[str, Any] | None:
625 """Get maximum target value found and corresponding parameters.
626
627 If there is a constraint present, the maximum value that fulfills the
628 constraint within the parameter bounds is returned.
629
630 Returns
631 -------
632 res: dict
633 A dictionary with the keys 'target' and 'params'. The value of
634 'target' is the maximum target value, and the value of 'params' is
635 a dictionary with the parameter names as keys and the parameter
636 values as values.
637 """
638 target_max = self._target_max()
639 if target_max is None:
640 return None
641
642 target = self.target[self.mask]
643 params = self.params[self.mask]
644 target_max_idx = np.argmax(target)
645
646 res = {"target": target_max, "params": self.array_to_params(params[target_max_idx])}
647
648 if self._constraint is not None:
649 constraint_values = self.constraint_values[self.mask]
650 res["constraint"] = constraint_values[target_max_idx]
651
652 return res
653
654 def res(self) -> list[dict[str, Any]]:
655 """Get all target values and constraint fulfillment for all parameters.

Callers 7

test_maxFunction · 0.95
test_max_with_constraintFunction · 0.95
test_max_categoricalFunction · 0.95
_updateMethod · 0.45
_target_maxMethod · 0.45
suggestMethod · 0.45

Calls 2

_target_maxMethod · 0.95
array_to_paramsMethod · 0.95

Tested by 4

test_maxFunction · 0.76
test_max_with_constraintFunction · 0.76
test_max_categoricalFunction · 0.76