Note
Go to the end to download the full example code.
plot_intermediate_values
- optuna.visualization.plot_intermediate_values(study)[source]
Plot intermediate values of all trials in a study.
- Parameters:
study (Study) – A
Study
object whose trials are plotted for their intermediate values.- Returns:
A
plotly.graph_objects.Figure
object.- Return type:
Figure
The following code snippet shows how to plot intermediate values.
import optuna
from plotly.io import show
def f(x):
return (x - 2) ** 2
def df(x):
return 2 * x - 4
def objective(trial):
lr = trial.suggest_float("lr", 1e-5, 1e-1, log=True)
x = 3
for step in range(128):
y = f(x)
trial.report(y, step=step)
if trial.should_prune():
raise optuna.TrialPruned()
gy = df(x)
x -= gy * lr
return y
sampler = optuna.samplers.TPESampler(seed=10)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=16)
fig = optuna.visualization.plot_intermediate_values(study)
show(fig)
Total running time of the script: (0 minutes 0.298 seconds)