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)
| 54 | |
| 55 | |
| 56 | def 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 | |
| 77 | def optimizer_UCB(optimizer: BaseLearner, X: modALinput, beta: float = 1) -> np.ndarray: |