-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
initialize function assumes keys are sorted and appear after 'target' in lexicographic order.
Code to reproduce:
from bayes_opt import BayesianOptimization
def target(a):
""" Function to return square of argument """
return a**2
def target2(x):
""" Same function with different name of argument """
return x**2
def test_bo_initialization(bo, func):
print('X: ', bo.x_init)
print('Y: ', bo.y_init)
mismatch = False
for x, y in zip(bo.x_init, bo.y_init):
if func(*x) != y:
mismatch = True
if mismatch:
print('ERROR: x_init and y_init do not match!')
else:
print('INFO: x_init and y_init match.')
bo = BayesianOptimization(target, {'a': (0, 10)})
bo.initialize(
{
'target': [1, 4, 9],
'a': [1, 2, 3],
})
test_bo_initialization(bo, target)
# mismatch is True!
# Output:
# X: [[1], [4], [9]]
# Y: [1, 2, 3]
# ERROR: x_init and y_init do not match!
bo2 = BayesianOptimization(target2, {'x': (0, 10)})
bo2.initialize(
{
'target': [1, 4, 9],
'x': [1, 2, 3]
})
test_bo_initialization(bo2, target2)
# mismatch is False.
# Output:
# X: [[1], [2], [3]]
# Y: [1, 4, 9]
# INFO: x_init and y_init match.Metadata
Metadata
Assignees
Labels
No labels