plot_param_importances

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

Plot hyperparameter importances (PedAnovaImportanceEvaluator by default).

See also

This function visualizes the results of optuna.importance.get_param_importances().

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.

    Note

    Optuna Dashboard also uses PedAnovaImportanceEvaluator, the default importance evaluator.

  • 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 legend. Names set via set_metric_names() will be used if target is None, overriding this argument.

Returns:

A plotly.graph_objects.Figure object.

Return type:

go.Figure

The following code snippet shows how to plot hyperparameter importances.

import optuna
from plotly.io import show


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)

fig = optuna.visualization.plot_param_importances(study)
show(fig)

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

Gallery generated by Sphinx-Gallery