Last active
November 1, 2022 00:49
-
-
Save e96031413/dfb89e90e397090406884516a58527c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bayes_opt import BayesianOptimization | |
from bayes_opt.logger import JSONLogger | |
from bayes_opt.event import Events | |
logger = JSONLogger(path="./tau_logs.json") | |
pbounds = {'tau1': (0.1, 0.2), 'tau2': (0.3, 0.4), | |
'tau3': (0.5, 0.6), 'tau4': (0.7, 0.8), | |
} | |
def search(tau1, tau2, tau3, tau4): | |
params = {} | |
params['tau1'] = tau1 | |
params['tau2'] = tau2 | |
params['tau3'] = tau3 | |
params['tau4'] = tau4 | |
score = Testing(tau1, tau2, tau3, tau4) | |
return score | |
# Run Bayesian Optimization | |
start = time.time() | |
bayes_optimizer = BayesianOptimization(search, random_state=1, pbounds=pbounds) | |
bayes_optimizer.subscribe(Events.OPTIMIZATION_STEP, logger) | |
bayes_optimizer.maximize(init_points=5, n_iter=25) | |
print('It takes %s minutes' % ((time.time() - start)/60)) | |
print(optimizer.max) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment