plot_timeline

optuna.visualization.matplotlib.plot_timeline(study)[源代码]

绘制研究的时间线。

参见

请参考 optuna.visualization.plot_timeline() 的示例。

参数:

study (Study) – 一个 Study 对象,其试验以生命周期绘制。

返回:

一个 matplotlib.axes.Axes 对象。

返回类型:

Axes

备注

作为实验性功能添加于 v3.2.0。接口可能会在新版本中发生变化,恕不另行通知。参见 https://github.com/optuna/optuna/releases/tag/v3.2.0

以下代码片段展示了如何绘制研究的时间线。

Timeline Plot
/Users/cw/baidu/code/fin_tool/github/optuna/docs/visualization_matplotlib_examples/optuna.visualization.matplotlib.timeline.py:29: ExperimentalWarning:

plot_timeline is experimental (supported from v3.2.0). The interface can change in the future.


<Axes: title={'center': 'Timeline Plot'}, xlabel='Datetime', ylabel='Trial'>

import time
import optuna


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,))

optuna.visualization.matplotlib.plot_timeline(study)

脚本总运行时间: (0 分钟 2.013 秒)

由 Sphinx-Gallery 生成的图库