Note
Go to the end to download the full example code.
plot_optimization_history
- optuna.visualization.plot_optimization_history(study, *, target=None, target_name='Objective Value', error_bar=False)[source]
スタディ内の全トライアルの最適化履歴をプロットします。
- Parameters:
study (Study | Sequence[Study]) – プロット対象のトライアルを含む
Study
オブジェクト。 複数のスタディを指定することで、それらの最適化履歴を比較できます。target (Callable[[FrozenTrial], float] | None) –
表示する値を指定する関数。
None
でstudy
が単一目的最適化の場合、 目的値がプロットされます。Note
study
が多目的最適化に使用されている場合、この引数を指定します。target_name (str) – 軸ラベルと凡例に表示するターゲットの名前。
error_bar (bool) – エラーバーを表示するかどうかのフラグ。
- Returns:
plotly.graph_objects.Figure
オブジェクト。- Return type:
Figure
The following code snippet shows how to plot optimization history.
import optuna
from plotly.io import show
def objective(trial):
x = trial.suggest_float("x", -100, 100)
y = trial.suggest_categorical("y", [-1, 0, 1])
return x**2 + y
sampler = optuna.samplers.TPESampler(seed=10)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=10)
fig = optuna.visualization.plot_optimization_history(study)
show(fig)
Total running time of the script: (0 minutes 0.123 seconds)