plot_pareto_front

optuna.visualization.matplotlib.plot_pareto_front(study, *, target_names=None, include_dominated_trials=True, axis_order=None, constraints_func=None, targets=None)[源代码]

绘制研究中的帕累托前沿。

参见

请参考 optuna.visualization.plot_pareto_front() 的示例。

参数:
  • study (Study) – A Study object whose trials are plotted for their objective values. study.n_objectives must be either 2 or 3 when targets is None.

  • target_names (list[str] | None) – Objective name list used as the axis titles. If None is specified, “Objective {objective_index}” is used instead. If targets is specified for a study that does not contain any completed trial, target_name must be specified.

  • include_dominated_trials (bool) – 一个标志,用于包含所有占优试验的目标值。

  • axis_order (list[int] | None) –

    A list of indices indicating the axis order. If None is specified, default order is used. axis_order and targets cannot be used at the same time.

    警告

    在v3.0.0中已弃用。此功能将在未来被移除。该功能的移除目前计划在v5.0.0版本中进行,但此计划可能会更改。请参阅https://github.com/optuna/optuna/releases/tag/v3.0.0。

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

    An optional function that computes the objective constraints. It must take a FrozenTrial and return the constraints. The return value must be a sequence of float s. A value strictly larger than 0 means that a constraint is violated. A value equal to or smaller than 0 is considered feasible. This specification is the same as in, for example, NSGAIISampler.

    如果有,试验被分为三类:可行且最佳、可行但非最佳、不可行。类别以不同颜色显示。这里,一个试验是否为最佳(在帕累托前沿)是根据忽略所有不可行试验来确定的。

    警告

    在 v4.0.0 中已弃用。此功能将在未来被移除。该功能的移除目前计划在 v6.0.0 进行,但此计划可能会更改。参见 https://github.com/optuna/optuna/releases/tag/v4.0.0

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

    A function that returns a tuple of target values to display. The argument to this function is FrozenTrial. targets must be None or return 2 or 3 values. axis_order and targets cannot be used at the same time. If the number of objectives is neither 2 nor 3, targets must be specified.

    备注

    在 v3.0.0 中作为实验性功能添加。接口可能会在更新版本中未经事先通知而更改。参见 https://github.com/optuna/optuna/releases/tag/v3.0.0

返回:

一个 matplotlib.axes.Axes 对象。

返回类型:

Axes

备注

作为实验性功能添加于 v2.8.0。接口可能会在更新版本中未经通知而发生变化。参见 https://github.com/optuna/optuna/releases/tag/v2.8.0

以下代码片段展示了如何绘制一个研究的帕累托前沿。

Pareto-front Plot
/Users/cw/baidu/code/fin_tool/github/optuna/docs/visualization_matplotlib_examples/optuna.visualization.matplotlib.pareto_front.py:27: ExperimentalWarning:

plot_pareto_front is experimental (supported from v2.8.0). The interface can change in the future.


<Axes: title={'center': 'Pareto-front Plot'}, xlabel='Objective 0', ylabel='Objective 1'>

import optuna


def objective(trial):
    x = trial.suggest_float("x", 0, 5)
    y = trial.suggest_float("y", 0, 3)

    v0 = 4 * x**2 + 4 * y**2
    v1 = (x - 5) ** 2 + (y - 5) ** 2
    return v0, v1


study = optuna.create_study(directions=["minimize", "minimize"])
study.optimize(objective, n_trials=50)

optuna.visualization.matplotlib.plot_pareto_front(study)

脚本总运行时间: (0 分钟 0.057 秒)

由 Sphinx-Gallery 生成的图库