plot_rank

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

ターゲット値のランクを色で表現した散布図としてパラメータ間の関係をプロットします。

指定パラメータが欠落しているトライアルはプロットされません。

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

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

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

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

    Note

    study が多目的最適化に使用されている場合はこの引数を指定します。

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

Returns:

plotly.graph_objects.Figure オブジェクト。

Return type:

Figure

Note

この関数は plotly >= 5.0.0 が必要です。

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

/mnt/nfs-mnj-hot-99-home/mshibata/sandbox/optuna-documentation-plamo-ja/optuna-doc-plamo-translation/tmp-optuna/optuna/_experimental.py:32: ExperimentalWarning:

Argument ``constraints_func`` is an experimental feature. The interface can change in the future.

import optuna
from plotly.io import show


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

    c0 = 400 - (x + y) ** 2
    trial.set_user_attr("constraint", [c0])

    return x**2 + y


def constraints(trial):
    return trial.user_attrs["constraint"]


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

fig = optuna.visualization.plot_rank(study, params=["x", "y"])
show(fig)

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

Gallery generated by Sphinx-Gallery