Class PercentilePruner
- Namespace
- OptunaSharp.Pruners
- Assembly
- OptunaSharp.dll
Pruner to keep the specified percentile of the trials.
Port of optuna/pruners/_percentile.py: PercentilePruner.
Prune if the best intermediate value is in the bottom percentile among trials at the same step.
public class PercentilePruner : BasePruner
- Inheritance
-
PercentilePruner
- Derived
- Inherited Members
Constructors
PercentilePruner(double, int, int, int, int)
Configures the reference percentile and evidence required before comparing trials.
public PercentilePruner(double percentile, int nStartupTrials = 5, int nWarmupSteps = 0, int intervalSteps = 1, int nMinTrials = 1)
Parameters
percentiledoublePercentile which must be between 0 and 100 inclusive (e.g., when given 25.0, top of 25th percentile trials are kept).
nStartupTrialsintPruning is disabled until the given number of trials finish in the same study.
nWarmupStepsintPruning is disabled while the current step is less than
nWarmupSteps; the earliest a trial can be pruned is atstep == nWarmupSteps.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.
nMinTrialsintMinimum number of reported trial results at a step to judge whether to prune. If the number of reported intermediate values from all trials at the current step is less than
nMinTrials, the trial will not be pruned.
Exceptions
- ValueError
The percentile is outside [0, 100], a startup/warmup count is negative, or an interval/minimum count 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.
Exceptions
- RuntimeError
The study has multiple objectives and the pruning rule requests its scalar direction.