MCPcopy Create free account
hub / github.com/modAL-python/modAL / optimizer_EI

Function optimizer_EI

modAL/acquisition.py:56–74  ·  view source on GitHub ↗

Expected improvement acquisition function for Bayesian optimization. Args: optimizer: The :class:`~modAL.models.BayesianOptimizer` object for which the utility is to be calculated. X: The samples for which the expected improvement is to be calculated. tradeoff: Valu

(optimizer: BaseLearner, X: modALinput, tradeoff: float = 0)

Source from the content-addressed store, hash-verified

54
55
56def optimizer_EI(optimizer: BaseLearner, X: modALinput, tradeoff: float = 0) -> np.ndarray:
57 """
58 Expected improvement acquisition function for Bayesian optimization.
59
60 Args:
61 optimizer: The :class:`~modAL.models.BayesianOptimizer` object for which the utility is to be calculated.
62 X: The samples for which the expected improvement is to be calculated.
63 tradeoff: Value controlling the tradeoff parameter.
64
65 Returns:
66 Expected improvement utility score.
67 """
68 try:
69 mean, std = optimizer.predict(X, return_std=True)
70 mean, std = mean.reshape(-1, ), std.reshape(-1, )
71 except NotFittedError:
72 mean, std = np.zeros(shape=(X.shape[0], 1)), np.ones(shape=(X.shape[0], 1))
73
74 return EI(mean, std, optimizer.y_max, tradeoff)
75
76
77def optimizer_UCB(optimizer: BaseLearner, X: modALinput, beta: float = 1) -> np.ndarray:

Callers 1

max_EIFunction · 0.85

Calls 2

EIFunction · 0.85
predictMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…