« Back to top page

Pruners

Pruners

Hyperband Pruner

Class or Function Names HyperbandPruner Example study = optuna.create_study( direction="maximize", pruner=optuna.pruners.HyperbandPruner( min_resource=1, max_resource=n_train_iter, reduction_factor=3 ), ) study.optimize(objective, n_trials=20) See example.py for a full example. Others See the documentation for more details.

Median Pruner

Class or Function Names MedianPruner Example import optuna from optuna.pruners import MedianPruner def objective(trial): s = 0 for step in range(20): x = trial.suggest_float(f"x_{step}", -5, 5) s += x**2 trial.report(s, step) if trial.should_prune(): raise optuna.TrialPruned() return s pruner = MedianPruner() study = optuna.create_study(pruner=pruner) study.optimize(objective, n_trials=20) Others See the documentation for more details.

Nop Pruner

Class or Function Names NopPruner Example study = optuna.create_study(direction="maximize", pruner=optuna.pruners.NopPruner()) study.optimize(objective, n_trials=20) See example.py for a full example. Others See the documentation for more details.

Patient Pruner

Class or Function Names PatientPruner Example study = optuna.create_study( direction="maximize", pruner=optuna.pruners.PatientPruner(optuna.pruners.MedianPruner(), patience=1), ) study.optimize(objective, n_trials=20) See example.py for a full example. Others See the documentation for more details.

Percentile Pruner

Class or Function Names PercentilePruner Example import optuna from optuna.pruners import PercentilePruner def objective(trial): s = 0 for step in range(20): x = trial.suggest_float(f"x_{step}", -5, 5) s += x**2 trial.report(s, step) if trial.should_prune(): raise optuna.TrialPruned() return s pruner = PercentilePruner(25.0) study = optuna.create_study(pruner=pruner) study.optimize(objective, n_trials=20) Others See the documentation for more details.

Successive Halving Pruner

Class or Function Names SuccessiveHalvingPruner Example study = optuna.create_study( direction="maximize", pruner=optuna.pruners.SuccessiveHalvingPruner() ) study.optimize(objective, n_trials=20) See example.py for a full example. Others See the documentation for more details.

Threshold Pruner

Class or Function Names ThresholdPruner Example study = create_study(pruner=ThresholdPruner(upper=1.0)) study.optimize(objective_for_upper, n_trials=10) study = create_study(pruner=ThresholdPruner(lower=0.0)) study.optimize(objective_for_lower, n_trials=10) See example.py for a full example. Others See the documentation for more details.

Wilcoxon Pruner

Class or Function Names WilcoxonPruner Example study = optuna.create_study(pruner=optuna.pruners.WilcoxonPruner(p_threshold=0.1)) study.optimize(objective, n_trials=100) See example.py for a full example. Others See the documentation for more details.