Skip to content

Commit f243cfc

Browse files
authored
Merge pull request #47 from amanbh/master
Fixes bug in initialize
2 parents 1ce5484 + ad5cab5 commit f243cfc

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

bayes_opt/bayesian_optimization.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,26 @@ def initialize(self, points_dict):
151151
Method to introduce points for which the target function value is known
152152
153153
:param points_dict:
154+
dictionary with self.keys and 'target' as keys, and list of
155+
corresponding values as values.
156+
157+
ex:
158+
{
159+
'target': [-1166.19102, -1142.71370, -1138.68293],
160+
'alpha': [7.0034, 6.6186, 6.0798],
161+
'colsample_bytree': [0.6849, 0.7314, 0.9540],
162+
'gamma': [8.3673, 3.5455, 2.3281],
163+
}
164+
165+
:return:
154166
"""
155167

156-
for points in zip(*(points_dict[k] for k in sorted(points_dict))):
157-
self.y_init.append(points[0])
158-
self.x_init.append(list(points[1:]))
168+
self.y_init.extend(points_dict['target'])
169+
for i in range(len(points_dict['target'])):
170+
all_points = []
171+
for key in self.keys:
172+
all_points.append(points_dict[key][i])
173+
self.x_init.append(all_points)
159174

160175
def initialize_df(self, points_df):
161176
"""

0 commit comments

Comments
 (0)