Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose random seed for MaxValueSearch #92

Open
kiudee opened this issue Dec 22, 2020 · 0 comments
Open

Expose random seed for MaxValueSearch #92

kiudee opened this issue Dec 22, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@kiudee
Copy link
Owner

kiudee commented Dec 22, 2020

class MaxValueSearch(UncertaintyAcquisition):
"""Select points based on their mutual information with the optimum value.
Parameters
----------
n_min_samples : int, default=1000
Number of samples for the optimum distribution
References
----------
[1] Wang, Z. & Jegelka, S.. (2017). Max-value Entropy Search for Efficient
Bayesian Optimization. Proceedings of the 34th International Conference
on Machine Learning, in PMLR 70:3627-3635
"""
def __call__(self, mu, std, *args, n_min_samples=1000, **kwargs):
def probf(x):
return np.exp(np.sum(st.norm.logcdf((x - mean) / std), axis=0))
# Negative sign, since the original algorithm is defined in terms of the maximum
mean = -mu
left = np.min(mean - 3 * std)
right = np.max(mean + 5 * std)
# Binary search for 3 percentiles
q1, med, q2 = [
brentq(lambda x: probf(x) - val, left, right,) for val in [0.25, 0.5, 0.75]
]
beta = (q1 - q2) / (np.log(np.log(4.0 / 3.0)) - np.log(np.log(4.0)))
alpha = med + beta * np.log(np.log(2.0))
max_values = (
-np.log(-np.log(np.random.rand(n_min_samples).astype(np.float32))) * beta
+ alpha
)
gamma = (max_values[None, :] - mean[:, None]) / std[:, None]
return (
np.sum(
gamma * st.norm().pdf(gamma) / (2.0 * st.norm().cdf(gamma))
- st.norm().logcdf(gamma),
axis=1,
)
/ n_min_samples
)

@kiudee kiudee added the enhancement New feature or request label Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant