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

Method suggest

bayes_opt/acquisition.py:1058–1148  ·  view source on GitHub ↗

Suggest a promising point to probe next. Parameters ---------- gp : GaussianProcessRegressor A fitted Gaussian Process. target_space : TargetSpace The target space to probe. n_random : int, default 10_000 Number of random

(
        self,
        gp: GaussianProcessRegressor,
        target_space: TargetSpace,
        n_random: int = 10_000,
        n_smart: int = 10,
        fit_gp: bool = True,
        random_state: int | RandomState | None = None,
    )

Source from the content-addressed store, hash-verified

1056 self.dummies = dummies
1057
1058 def suggest(
1059 self,
1060 gp: GaussianProcessRegressor,
1061 target_space: TargetSpace,
1062 n_random: int = 10_000,
1063 n_smart: int = 10,
1064 fit_gp: bool = True,
1065 random_state: int | RandomState | None = None,
1066 ) -> NDArray[Float]:
1067 """Suggest a promising point to probe next.
1068
1069 Parameters
1070 ----------
1071 gp : GaussianProcessRegressor
1072 A fitted Gaussian Process.
1073
1074 target_space : TargetSpace
1075 The target space to probe.
1076
1077 n_random : int, default 10_000
1078 Number of random samples to use.
1079
1080 n_smart : int, default 10
1081 Number of starting points for the L-BFGS-B optimizer.
1082
1083 fit_gp : bool, default True
1084 Unused, since the GP is always fitted to the dummy target space.
1085 Remains for compatibility with the base class.
1086
1087 random_state : int, RandomState, default None
1088 Random state to use for the optimization.
1089
1090 Returns
1091 -------
1092 np.ndarray
1093 Suggested point to probe next.
1094 """
1095 if len(target_space) == 0:
1096 msg = (
1097 "Cannot suggest a point without previous samples. Use "
1098 " target_space.random_sample() to generate a point and "
1099 " target_space.probe(*) to evaluate it."
1100 )
1101 raise TargetSpaceEmptyError(msg)
1102
1103 if target_space.constraint is not None:
1104 msg = (
1105 f"Received constraints, but acquisition function {type(self)} "
1106 "does not support constrained optimization."
1107 )
1108 raise ConstraintNotSupportedError(msg)
1109
1110 # Check if any dummies have been evaluated and remove them
1111 self._remove_expired_dummies(target_space)
1112
1113 # Create a copy of the target space
1114 dummy_target_space = self._copy_target_space(target_space)
1115

Callers 2

test_constant_liarFunction · 0.95

Calls 8

_copy_target_spaceMethod · 0.95
_fit_gpMethod · 0.80
maxMethod · 0.45
registerMethod · 0.45
suggestMethod · 0.45

Tested by 2

test_constant_liarFunction · 0.76