Optuna

class Optuna(direction: Union[Literal['minimize', 'maximize'], optuna.study._study_direction.StudyDirection], study_name: Optional[str] = None, sampler: Optional[optuna.samplers._base.BaseSampler] = None, storage: Optional[optuna.storages._base.BaseStorage] = None, pruner: Optional[optuna.pruners._base.BasePruner] = None, directions: Optional[Sequence[Union[Literal['minimize', 'maximize'], optuna.study._study_direction.StudyDirection]]] = None, load_if_exists: bool = True)[source]

Bases: object

Class for encapsulate work with Optuna.

Init wrapper for Optuna.

Parameters
  • direction (Union[Literal['minimize', 'maximize'], optuna.study._study_direction.StudyDirection]) – optuna direction

  • study_name (Optional[str]) – name of study

  • sampler (Optional[optuna.samplers._base.BaseSampler]) – optuna sampler to use

  • storage (Optional[optuna.storages._base.BaseStorage]) – storage to use

  • pruner (Optional[optuna.pruners._base.BasePruner]) – optuna pruner

  • directions (Optional[Sequence[Union[Literal['minimize', 'maximize'], optuna.study._study_direction.StudyDirection]]]) – directions to optimize in case of multi-objective optimization

  • load_if_exists (bool) – load study from storage if it exists or raise exception if it doesn’t

Inherited-members

Methods

tune(objective[, n_trials, timeout, runner])

Call optuna optimize for chosen Runner.

Attributes

study

Get optuna study.

tune(objective: Callable[[optuna.trial._trial.Trial], Union[float, Sequence[float]]], n_trials: Optional[int] = None, timeout: Optional[int] = None, runner: Optional[etna.auto.runner.base.AbstractRunner] = None, **kwargs)[source]

Call optuna optimize for chosen Runner.

Parameters
  • objective (Callable[[optuna.trial._trial.Trial], Union[float, Sequence[float]]]) – objective function to optimize in optuna style

  • n_trials (Optional[int]) – number of trials to run. N.B. in case of parallel runner, this is number of trials per worker

  • timeout (Optional[int]) – timeout for optimization. N.B. in case of parallel runner, this is timeout per worker

  • kwargs – additional arguments to pass to optuna.study.Study.optimize()

  • runner (Optional[etna.auto.runner.base.AbstractRunner]) –

property study: optuna.study.study.Study

Get optuna study.