plot_rank

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

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

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

See also

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

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

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

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

Rank (Objective Value)
/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.

/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.rank.py:33: ExperimentalWarning:

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


<Axes: title={'center': 'Rank (Objective Value)'}, xlabel='x', ylabel='y'>

import optuna


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)

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

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

Gallery generated by Sphinx-Gallery