optuna.importance¶
-
optuna.importance.
get_param_importances
(study: optuna.study.Study, evaluator: optuna.importance._base.BaseImportanceEvaluator = None, params: Optional[List[str]] = None) → Dict[str, float][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
isNone
, 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, alist
of parameter names can be specified viaparams
. 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 – An optimized study.
evaluator – An importance evaluator object that specifies which algorithm to base the importance assessment on. Defaults to
MeanDecreaseImpurityImportanceEvaluator
.params – A list of names of parameters to assess. If
None
, all parameters that are present in all of the completed trials are assessed.
- Returns
An
collections.OrderedDict
where the keys are parameter names and the values are assessed importances.
Note
Added in v1.3.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.3.0.
-
class
optuna.importance.
FanovaImportanceEvaluator
[source]¶ fANOVA parameter importance evaluator.
Note
Requires the fanova Python package.
Note
Added in v1.3.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.3.0.
-
evaluate
(study: optuna.study.Study, params: Optional[List[str]]) → Dict[str, float][source]¶ Evaluate parameter importances based on completed trials in the given study.
Note
This method is not meant to be called by library users.
See also
Please refer to
get_param_importances()
for how a concrete evaluator should implement this method.- Parameters
study – An optimized study.
params – A list of names of parameters to assess. If
None
, all parameters that are present in all of the completed trials are assessed.
- Returns
An
collections.OrderedDict
where the keys are parameter names and the values are assessed importances.
-
-
class
optuna.importance.
MeanDecreaseImpurityImportanceEvaluator
(n_estimators: int = 16, max_depth: int = 64, random_state: Optional[int] = None)[source]¶ Mean Decrease Impurity (MDI) parameter importance evaluator.
This evaluator fits a random forest that predicts objective values given hyperparameter configurations. Feature importances are then computed using MDI.
Note
This evaluator requires the sklean Python package and is based on sklearn.ensemble.RandomForestClassifier.feature_importances_.
- Parameters
n_estimators – Number of trees in the random forest.
max_depth – The maximum depth of each tree in the random forest.
random_seed – Seed for the random forest.
Note
Added in v1.5.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.5.0.
-
evaluate
(study: optuna.study.Study, params: Optional[List[str]]) → Dict[str, float][source]¶ Evaluate parameter importances based on completed trials in the given study.
Note
This method is not meant to be called by library users.
See also
Please refer to
get_param_importances()
for how a concrete evaluator should implement this method.- Parameters
study – An optimized study.
params – A list of names of parameters to assess. If
None
, all parameters that are present in all of the completed trials are assessed.
- Returns
An
collections.OrderedDict
where the keys are parameter names and the values are assessed importances.