Table of Contents

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

lower double?

A minimum value which determines whether pruner prunes or not. If an intermediate value is smaller than lower, it prunes.

upper double?

A maximum value which determines whether pruner prunes or not. If an intermediate value is larger than upper, it prunes.

nWarmupSteps int

Pruning is disabled if the step is less than the given number of warmup steps.

intervalSteps int

Interval 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

study Study

Study object of the target study.

trial FrozenTrial

FrozenTrial object of the target trial. Take a copy before modifying this object.

Returns

bool

A boolean value representing whether the trial should be pruned.

See Also