Note
Go to the end to download the full example code.
plot_timeline
- optuna.visualization.plot_timeline(study)[source]
Plot the timeline of a study.
- Parameters:
study (Study) – A
Study
object whose trials are plotted with their lifetime.- Returns:
A
plotly.graph_objects.Figure
object.- Return type:
Figure
The following code snippet shows how to plot the timeline of a study. Timeline plot can visualize trials with overlapping execution time (e.g., in distributed environments).
import time
import optuna
from plotly.io import show
def objective(trial):
x = trial.suggest_float("x", 0, 1)
time.sleep(x * 0.1)
if x > 0.8:
raise ValueError()
if x > 0.4:
raise optuna.TrialPruned()
return x ** 2
study = optuna.create_study(direction="minimize")
study.optimize(
objective, n_trials=50, n_jobs=2, catch=(ValueError,)
)
fig = optuna.visualization.plot_timeline(study)
show(fig)
Total running time of the script: (0 minutes 1.995 seconds)