Skip to content

Commit a470d2d

Browse files
committed
Addresses issue #25
1 parent 52a2be5 commit a470d2d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

bayes_opt/bayesian_optimization.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,9 @@ def initialize(self, points_dict):
157157
:return:
158158
"""
159159

160-
for target in points_dict:
161-
162-
self.y_init.append(target)
163-
164-
all_points = []
165-
for key in self.keys:
166-
all_points.append(points_dict[target][key])
167-
168-
self.x_init.append(all_points)
160+
for points in zip(*(points_dict[k] for k in sorted(points_dict))):
161+
self.y_init.append(points[0])
162+
self.x_init.append(list(points[1:]))
169163

170164
def initialize_df(self, points_df):
171165
"""

examples/usage.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@
2020
# tell that to the optimizer.
2121
# Here we pass a dictionary with target values as keys of another
2222
# dictionary with parameters names and their corresponding value.
23-
bo.initialize({-2: {'x': 1, 'y': 0}, -1.251: {'x': 1, 'y': 1.5}})
23+
bo.initialize(
24+
{
25+
'target': [-1, -1],
26+
'x': [1, 1],
27+
'y': [0, 2]
28+
}
29+
)
2430

2531
# Once we are satisfied with the initialization conditions
2632
# we let the algorithm do its magic by calling the maximize()
2733
# method.
28-
bo.maximize(init_points=5, n_iter=15, kappa=3.29)
34+
bo.maximize(init_points=5, n_iter=15, kappa=2)
2935

3036
# The output values can be accessed with self.res
3137
print(bo.res['max'])

0 commit comments

Comments
 (0)