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

Method suggest

bayes_opt/acquisition.py:1252–1319  ·  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

1250 self.previous_candidates = None
1251
1252 def suggest(
1253 self,
1254 gp: GaussianProcessRegressor,
1255 target_space: TargetSpace,
1256 n_random: int = 10_000,
1257 n_smart: int = 10,
1258 fit_gp: bool = True,
1259 random_state: int | RandomState | None = None,
1260 ) -> NDArray[Float]:
1261 """Suggest a promising point to probe next.
1262
1263 Parameters
1264 ----------
1265 gp : GaussianProcessRegressor
1266 A fitted Gaussian Process.
1267
1268 target_space : TargetSpace
1269 The target space to probe.
1270
1271 n_random : int, default 10_000
1272 Number of random samples to use.
1273
1274 n_smart : int, default 10
1275 Number of starting points for the L-BFGS-B optimizer.
1276
1277 fit_gp : bool, default True
1278 Whether to fit the Gaussian Process to the target space.
1279 Set to False if the GP is already fitted.
1280
1281 random_state : int, RandomState, default None
1282 Random state to use for the optimization.
1283
1284 Returns
1285 -------
1286 np.ndarray
1287 Suggested point to probe next.
1288 """
1289 if len(target_space) == 0:
1290 msg = (
1291 "Cannot suggest a point without previous samples. Use "
1292 " target_space.random_sample() to generate a point and "
1293 " target_space.probe(*) to evaluate it."
1294 )
1295 raise TargetSpaceEmptyError(msg)
1296 self.i += 1
1297 random_state = ensure_rng(random_state)
1298 if fit_gp:
1299 self._fit_gp(gp=gp, target_space=target_space)
1300
1301 # Update the gains of the base acquisition functions
1302 if self.previous_candidates is not None:
1303 self._update_gains(gp)
1304
1305 # Suggest a point using each base acquisition function
1306 x_max = [
1307 base_acq.suggest(
1308 gp=gp,
1309 target_space=target_space,

Callers 11

test_gphedge_integrationFunction · 0.95
verify_optimizers_matchFunction · 0.45
suggestMethod · 0.45
suggestMethod · 0.45
suggestMethod · 0.45
suggestMethod · 0.45
postMethod · 0.45
duplicate_point.pyFile · 0.45

Calls 5

_update_gainsMethod · 0.95
ensure_rngFunction · 0.90
_fit_gpMethod · 0.80