Note
Go to the end to download the full example code.
plot_edf
- optuna.visualization.plot_edf(study, *, target=None, target_name='Objective Value')[source]
スタディの目的関数値 EDF (経験分布関数) をプロットします。
EDF のプロット時には完了したトライアルのみが考慮されます。
Note
EDF は探索空間の分析と改善に有用です。 例えば、論文 Designing Network Design Spaces で EDF の実用的な使用例を確認できます。
Note
プロットされる EDF は、目的関数の値が目的空間上で一様分布していると仮定しています。
- Parameters:
- Returns:
plotly.graph_objects.Figure
オブジェクト。- Return type:
Figure
The following code snippet shows how to plot EDF.
import math
import optuna
from plotly.io import show
def ackley(x, y):
a = 20 * math.exp(-0.2 * math.sqrt(0.5 * (x**2 + y**2)))
b = math.exp(0.5 * (math.cos(2 * math.pi * x) + math.cos(2 * math.pi * y)))
return -a - b + math.e + 20
def objective(trial, low, high):
x = trial.suggest_float("x", low, high)
y = trial.suggest_float("y", low, high)
return ackley(x, y)
sampler = optuna.samplers.RandomSampler(seed=10)
# Widest search space.
study0 = optuna.create_study(study_name="x=[0,5), y=[0,5)", sampler=sampler)
study0.optimize(lambda t: objective(t, 0, 5), n_trials=500)
# Narrower search space.
study1 = optuna.create_study(study_name="x=[0,4), y=[0,4)", sampler=sampler)
study1.optimize(lambda t: objective(t, 0, 4), n_trials=500)
# Narrowest search space but it doesn't include the global optimum point.
study2 = optuna.create_study(study_name="x=[1,3), y=[1,3)", sampler=sampler)
study2.optimize(lambda t: objective(t, 1, 3), n_trials=500)
fig = optuna.visualization.plot_edf([study0, study1, study2])
show(fig)
Total running time of the script: (0 minutes 0.896 seconds)