MCPcopy
hub / github.com/hyperopt/hyperopt / stop_fn

Function stop_fn

hyperopt/early_stop.py:20–44  ·  view source on GitHub ↗
(trials, best_loss=None, iteration_no_progress=0)

Source from the content-addressed store, hash-verified

18 """
19
20 def stop_fn(trials, best_loss=None, iteration_no_progress=0):
21 new_loss = trials.trials[len(trials.trials) - 1]["result"]["loss"]
22 if best_loss is None:
23 return False, [new_loss, iteration_no_progress + 1]
24 best_loss_threshold = best_loss - abs(best_loss * (percent_increase / 100.0))
25 if new_loss < best_loss_threshold:
26 best_loss = new_loss
27 iteration_no_progress = 0
28 else:
29 iteration_no_progress += 1
30 logger.debug(
31 "No progress made: %d iteration on %d. best_loss=%.2f, best_loss_threshold=%.2f, new_loss=%.2f"
32 % (
33 iteration_no_progress,
34 iteration_stop_count,
35 best_loss,
36 best_loss_threshold,
37 new_loss,
38 )
39 )
40
41 return (
42 iteration_no_progress >= iteration_stop_count,
43 [best_loss, iteration_no_progress],
44 )
45
46 return stop_fn

Callers

nothing calls this directly

Calls 1

debugMethod · 0.80

Tested by

no test coverage detected