plot_param_importances

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

Plot hyperparameter importances (PedAnovaImportanceEvaluator by default) with Matplotlib.

See also

Please refer to optuna.visualization.plot_param_importances() for an example.

Parameters:
  • study (Study) – An optimized study.

  • evaluator (BaseImportanceEvaluator | None) –

    An importance evaluator object that specifies which algorithm to base the importance assessment on. Defaults to PedAnovaImportanceEvaluator. For details on this evaluator, please refer to the following papers:

    When using this evaluator in your project, please consider citing both papers.

  • params (list[str] | None) – A list of names of parameters to assess. If None, PedAnovaImportanceEvaluator assesses all parameters that appear in completed trials, including conditional parameters, while other evaluators assess parameters present in all completed trials. If specified, only the specified parameters are assessed. When using PedAnovaImportanceEvaluator, each specified parameter must appear in at least one completed trial. When using other evaluators, at least one completed trial must contain all specified parameters.

  • target (Callable[[FrozenTrial], float] | None) – A function that returns the value used to evaluate and display importances. If None, objective values are used for single-objective optimization. For multi-objective optimization, all objectives will be plotted if target is None. Specify target, for example target=lambda t: t.values[0], to plot importances for a specific objective.

  • target_name (str) – Target’s name to display on the axis label. Names set via set_metric_names() will be used if target is None, overriding this argument.

Returns:

A matplotlib.axes.Axes object.

Return type:

Axes

Note

Added in v2.2.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v2.2.0.

The following code snippet shows how to plot hyperparameter importances.

Hyperparameter Importances
/home/docs/checkouts/readthedocs.org/user_builds/optuna/checkouts/latest/docs/visualization_matplotlib_examples/optuna.visualization.matplotlib.param_importances.py:26: ExperimentalWarning: optuna.visualization.matplotlib._param_importances.plot_param_importances is experimental (supported from v2.2.0). The interface can change in the future.
  optuna.visualization.matplotlib.plot_param_importances(study)

<Axes: title={'left': 'Hyperparameter Importances'}, xlabel='Hyperparameter Importance', ylabel='Hyperparameter'>

import optuna


def objective(trial):
    x = trial.suggest_int("x", 0, 2)
    y = trial.suggest_float("y", -1.0, 1.0)
    z = trial.suggest_float("z", 0.0, 1.5)
    return x**2 + y**3 - z**4


sampler = optuna.samplers.RandomSampler(seed=10)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=100)

optuna.visualization.matplotlib.plot_param_importances(study)

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

Gallery generated by Sphinx-Gallery