@@ 287-337 (lines=51) @@ | ||
284 | assert n_performed_iter == n_iter |
|
285 | ||
286 | ||
287 | def test_early_stop_7(): |
|
288 | def objective_function(para): |
|
289 | return para["x1"] |
|
290 | ||
291 | search_space = { |
|
292 | "x1": list(np.arange(0, 100, 0.01)), |
|
293 | } |
|
294 | ||
295 | n_iter_no_change = 5 |
|
296 | early_stopping = { |
|
297 | "n_iter_no_change": n_iter_no_change, |
|
298 | "tol_abs": None, |
|
299 | "tol_rel": 10, |
|
300 | } |
|
301 | ||
302 | start1 = {"x1": 1} |
|
303 | start2 = {"x1": 1.09} |
|
304 | start3 = {"x1": 1.20} |
|
305 | ||
306 | warm_start_l = [ |
|
307 | start1, |
|
308 | start1, |
|
309 | start1, |
|
310 | start1, |
|
311 | start1, |
|
312 | start2, |
|
313 | start2, |
|
314 | start2, |
|
315 | start3, |
|
316 | start3, |
|
317 | start3, |
|
318 | ] |
|
319 | n_iter = len(warm_start_l) |
|
320 | ||
321 | hyper = Hyperactive() |
|
322 | hyper.add_search( |
|
323 | objective_function, |
|
324 | search_space, |
|
325 | n_iter=n_iter, |
|
326 | initialize={"warm_start": warm_start_l}, |
|
327 | early_stopping=early_stopping, |
|
328 | ) |
|
329 | hyper.run() |
|
330 | ||
331 | search_data = hyper.search_data(objective_function) |
|
332 | n_performed_iter = len(search_data) |
|
333 | ||
334 | print("\n n_performed_iter \n", n_performed_iter) |
|
335 | print("\n n_iter_no_change \n", n_iter_no_change) |
|
336 | ||
337 | assert n_performed_iter == (n_iter_no_change + 1) |
|
338 | ||
@@ 173-223 (lines=51) @@ | ||
170 | assert n_performed_iter == n_iter |
|
171 | ||
172 | ||
173 | def test_early_stop_5(): |
|
174 | def objective_function(para): |
|
175 | return para["x1"] |
|
176 | ||
177 | search_space = { |
|
178 | "x1": list(np.arange(0, 100, 0.01)), |
|
179 | } |
|
180 | ||
181 | n_iter_no_change = 5 |
|
182 | early_stopping = { |
|
183 | "n_iter_no_change": n_iter_no_change, |
|
184 | "tol_abs": 0.1, |
|
185 | "tol_rel": None, |
|
186 | } |
|
187 | ||
188 | start1 = {"x1": 0} |
|
189 | start2 = {"x1": 0.09} |
|
190 | start3 = {"x1": 0.20} |
|
191 | ||
192 | warm_start_l = [ |
|
193 | start1, |
|
194 | start1, |
|
195 | start1, |
|
196 | start1, |
|
197 | start1, |
|
198 | start2, |
|
199 | start2, |
|
200 | start2, |
|
201 | start3, |
|
202 | start3, |
|
203 | start3, |
|
204 | ] |
|
205 | n_iter = len(warm_start_l) |
|
206 | ||
207 | hyper = Hyperactive() |
|
208 | hyper.add_search( |
|
209 | objective_function, |
|
210 | search_space, |
|
211 | n_iter=n_iter, |
|
212 | initialize={"warm_start": warm_start_l}, |
|
213 | early_stopping=early_stopping, |
|
214 | ) |
|
215 | hyper.run() |
|
216 | ||
217 | search_data = hyper.search_data(objective_function) |
|
218 | n_performed_iter = len(search_data) |
|
219 | ||
220 | print("\n n_performed_iter \n", n_performed_iter) |
|
221 | print("\n n_iter_no_change \n", n_iter_no_change) |
|
222 | ||
223 | assert n_performed_iter == (n_iter_no_change + 1) |
|
224 | ||
225 | ||
226 | def test_early_stop_6(): |