Skip to content

Instantly share code, notes, and snippets.

@avisheknag17
Last active June 12, 2021 15:06
Show Gist options
  • Save avisheknag17/df882afcbca7ef9830e88eef251beb0e to your computer and use it in GitHub Desktop.
Save avisheknag17/df882afcbca7ef9830e88eef251beb0e to your computer and use it in GitHub Desktop.
def _get_expected_improvement(self, x_new):
# Using estimate from Gaussian surrogate instead of actual function for
# a new trial data point to avoid cost
mean_y_new, sigma_y_new = self.gauss_pr.predict(np.array([x_new]), return_std=True)
sigma_y_new = sigma_y_new.reshape(-1,1)
if sigma_y_new == 0.0:
return 0.0
# Using estimates from Gaussian surrogate instead of actual function for
# entire prior distribution to avoid cost
mean_y = self.gauss_pr.predict(self.x_init)
max_mean_y = np.max(mean_y)
z = (mean_y_new - max_mean_y) / sigma_y_new
exp_imp = (mean_y_new - max_mean_y) * norm.cdf(z) + sigma_y_new * norm.pdf(z)
return exp_imp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment