Upper confidence bound 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 upper confidence bound is to be calculated. beta: Valu
(optimizer: BaseLearner, X: modALinput, beta: float = 1)
| 75 | |
| 76 | |
| 77 | def optimizer_UCB(optimizer: BaseLearner, X: modALinput, beta: float = 1) -> np.ndarray: |
| 78 | """ |
| 79 | Upper confidence bound acquisition function for Bayesian optimization. |
| 80 | |
| 81 | Args: |
| 82 | optimizer: The :class:`~modAL.models.BayesianOptimizer` object for which the utility is to be calculated. |
| 83 | X: The samples for which the upper confidence bound is to be calculated. |
| 84 | beta: Value controlling the beta parameter. |
| 85 | |
| 86 | Returns: |
| 87 | Upper confidence bound utility score. |
| 88 | """ |
| 89 | try: |
| 90 | mean, std = optimizer.predict(X, return_std=True) |
| 91 | mean, std = mean.reshape(-1, ), std.reshape(-1, ) |
| 92 | except NotFittedError: |
| 93 | mean, std = np.zeros(shape=(X.shape[0], 1)), np.ones(shape=(X.shape[0], 1)) |
| 94 | |
| 95 | return UCB(mean, std, beta) |
| 96 | |
| 97 | |
| 98 | """ |