« Back to top page

Median Pruner

Pruner using the median stopping rule.

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.

Package
pruners/median
Author
Optuna team
License
MIT License
Verified Optuna version
  • 3.6.1
Last update
2024-07-05