optuna.importance.get_param_importances

optuna.importance.get_param_importances(study, *, evaluator=None, params=None, target=None)[source]

Evaluate parameter importances based on completed trials in the given study.

The parameter importances are returned as a dictionary where the keys consist of parameter names and their values importances. The importances are represented by floating point numbers that sum to 1.0 over the entire dictionary. The higher the value, the more important. The returned dictionary is of type collections.OrderedDict and is ordered by its values in a descending order.

If params is None, all parameter that are present in all of the completed trials are assessed. This implies that conditional parameters will be excluded from the evaluation. To assess the importances of conditional parameters, a list of parameter names can be specified via params. If specified, only completed trials that contain all of the parameters will be considered. If no such trials are found, an error will be raised.

If the given study does not contain completed trials, an error will be raised.

Note

If params is specified as an empty list, an empty dictionary is returned.

See also

See plot_param_importances() to plot importances.

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

  • evaluator (Optional[optuna.importance._base.BaseImportanceEvaluator]) – An importance evaluator object that specifies which algorithm to base the importance assessment on. Defaults to FanovaImportanceEvaluator.

  • params (Optional[List[str]]) – A list of names of parameters to assess. If None, all parameters that are present in all of the completed trials are assessed.

  • target (Optional[Callable[[optuna.trial._frozen.FrozenTrial], float]]) –

    A function to specify the value to evaluate importances. If it is None and study is being used for single-objective optimization, the objective values are used.

    Note

    Specify this argument if study is being used for multi-objective optimization. For example, to get the hyperparameter importance of the first objective, use target=lambda t: t.values[0] for the target parameter.

Returns

An collections.OrderedDict where the keys are parameter names and the values are assessed importances.

Raises

ValueError – If target is None and study is being used for multi-objective optimization.

Return type

Dict[str, float]