pg.early_stopping.early_stop_by_value¶
Accessible via pg.early_stopping.early_stop_by_value
.
- class early_stop_by_value(step_values, metric='reward', maximize=True)¶
Bases:
pg.Functor
Step-wise early stopping policy based on the value of reward/metric.
Example:
policy = early_stop_by_value([ # Stop at step 1 if trial reward is less than 0.2. (1, 0.2), # Stop at step 2 if trial reward is less than 0.8. (2, 0.8), ])()
- Parameters:
step_values –
A list of tuple (gating step, value threshold). gating step - At which step this rule will be triggered. value threshold - A float number indicating the threshold value for
early stopping.
metric – Based on which metric the value should be compared against. Use str for metric name or a callable object that takes a measurement object at a given step as input and returns a float value.
maximize – If True, reward or metric value below the threshold will be stopped, otherwise trials with values above the threshold will be stopped.
- Returns:
A StepWise early stopping policy.