Class ThresholdPruner
- Namespace
- OptunaSharp.Pruners
- Assembly
- OptunaSharp.dll
Pruner to detect outlying metrics of the trials.
Port of optuna/pruners/_threshold.py: ThresholdPruner.
Prune if a metric exceeds upper threshold, falls behind lower threshold or reaches
NaN.
public class ThresholdPruner : BasePruner
- Inheritance
-
ThresholdPruner
- Inherited Members
Constructors
ThresholdPruner(double?, double?, int, int)
Configures acceptable report bounds and the schedule on which they are checked.
public ThresholdPruner(double? lower = null, double? upper = null, int nWarmupSteps = 0, int intervalSteps = 1)
Parameters
lowerdouble?A minimum value which determines whether pruner prunes or not. If an intermediate value is smaller than lower, it prunes.
upperdouble?A maximum value which determines whether pruner prunes or not. If an intermediate value is larger than upper, it prunes.
nWarmupStepsintPruning is disabled if the step is less than the given number of warmup steps.
intervalStepsintInterval in number of steps between the pruning checks, offset by the warmup steps. If no value has been reported at the time of a pruning check, that particular check will be postponed until a value is reported. Value must be at least 1.
Exceptions
- TypeError
Neither bound is supplied.
- ValueError
The lower bound exceeds the upper bound, warmup is negative, or the interval is below one.
Methods
Prune(Study, FrozenTrial)
Judge whether the trial should be pruned based on the reported values.
Note that this method is not supposed to be called by library users. Instead, Report(double, long) and ShouldPrune() provide user interfaces to implement pruning mechanism in an objective function.
public override bool Prune(Study study, FrozenTrial trial)
Parameters
studyStudyStudy object of the target study.
trialFrozenTrialFrozenTrial object of the target trial. Take a copy before modifying this object.
Returns
- bool
A boolean value representing whether the trial should be pruned.