pg.tuning.EarlyStoppingPolicy¶
Accessible via pg.tuning.EarlyStoppingPolicy
.
- class EarlyStoppingPolicy[source]¶
Bases:
pg.Object
Interface for early stopping policy.
Methods:
recover
(history)Recover states by replaying the trial history.
setup
(dna_spec)Setup states of an early stopping policy based on dna_spec.
should_stop_early
(trial)Should stop the input trial early based on its measurements.
- recover(history)[source]¶
Recover states by replaying the trial history.
Subclass can override.
NOTE: recover will always be called before the first should_stop_early is called. It could be called multiple times if there are multiple source of history, e.g: trials from a previous study and existing trials from current study.
The default behavior is to replay should_stop_early on all trials that contain all intermediate measurements.
- Return type:
- Parameters:
history – An iterable object of trials.
- setup(dna_spec)[source]¶
Setup states of an early stopping policy based on dna_spec.
- Return type:
- Parameters:
dna_spec – DNASpec for DNA to propose.
- Raises:
RuntimeError – if dna_spec is not supported.