Note
Go to the end to download the full example code.
plot_rank
- optuna.visualization.plot_rank(study, params=None, *, target=None, target_name='Objective Value')[source]
ターゲット値のランクを色で表現した散布図としてパラメータ間の関係をプロットします。
指定パラメータが欠落しているトライアルはプロットされません。
- Parameters:
target (Callable[[FrozenTrial], float] | None) –
表示する値を指定する関数。
None
でstudy
が単一目的最適化に使用されている場合、目的値がプロットされます。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)