plot_intermediate_values

optuna.visualization.matplotlib.plot_intermediate_values(study)[source]

スタディ内の全トライアルの中間値を Matplotlib でプロットします。

See also

使用例については optuna.visualization.plot_intermediate_values() を参照してください。

Note

生成される凡例のスタイルを調整するには matplotlib.pyplot.legend を参照してください。

Parameters:

study (Study) – 中間値をプロットする Study オブジェクト。

Returns:

matplotlib.axes.Axes オブジェクト。

Return type:

Axes

Note

v2.2.0 で実験的機能として追加されました。新しいバージョンでは予告なくインターフェースが変更される可能性があります。 https://github.com/optuna/optuna/releases/tag/v2.2.0 を参照してください。

The following code snippet shows how to plot intermediate values.

Intermediate Values Plot
/mnt/nfs-mnj-hot-99-home/mshibata/sandbox/optuna-documentation-plamo-ja/optuna-doc-plamo-translation/tmp-optuna/docs/visualization_matplotlib_examples/optuna.visualization.matplotlib.intermediate_values.py:44: ExperimentalWarning:

plot_intermediate_values is experimental (supported from v2.2.0). The interface can change in the future.


<Axes: title={'center': 'Intermediate Values Plot'}, xlabel='Step', ylabel='Intermediate Value'>

import optuna


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)

optuna.visualization.matplotlib.plot_intermediate_values(study)

Total running time of the script: (0 minutes 0.302 seconds)

Gallery generated by Sphinx-Gallery