plot_contour

optuna.visualization.matplotlib.plot_contour(study, params=None, *, target=None, target_name='Objective Value')[source]

Matplotlibを使用してスタディのパラメータ関係を等高線プロットとして表示します。

注意: パラメータに欠損値が含まれている場合、欠損値のあるトライアルはプロットされません。

See also

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

Parameters:
  • study (Study) – ターゲット値に基づいてトライアルをプロットする Study オブジェクト。

  • params (list[str] | None) – 可視化するパラメータリスト。デフォルトは全てのパラメータです。

  • target (Callable[[FrozenTrial], float] | None) –

    表示する値を指定する関数。Nonestudy が単一目的最適化の場合、目的値がプロットされます。

    Note

    多目的最適化で study を使用する場合はこの引数を指定してください。

  • target_name (str) – カラーバーに表示するターゲットの名前。

Returns:

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

Return type:

Axes

Note

target 引数が None でない場合、または Studydirectionminimize の場合、カラーマップが反転します。

Note

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

The following code snippet shows how to plot the parameter relationship as contour plot.

Contour 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.contour.py:25: ExperimentalWarning:

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


<Axes: title={'center': 'Contour Plot'}, xlabel='x', ylabel='y'>

import optuna


def objective(trial):
    x = trial.suggest_float("x", -100, 100)
    y = trial.suggest_categorical("y", [-1, 0, 1])
    return x**2 + y


sampler = optuna.samplers.TPESampler(seed=10)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=30)

optuna.visualization.matplotlib.plot_contour(study, params=["x", "y"])

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

Gallery generated by Sphinx-Gallery