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

Function optimizer_UCB

modAL/acquisition.py:77–95  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

75
76
77def 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"""

Callers 1

max_UCBFunction · 0.85

Calls 2

UCBFunction · 0.85
predictMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…