get_feature_importance

Calculate and return the feature importances.

Method call format

get_feature_importance(data=None,
                       type=EFstrType.FeatureImportance,
                       prettified=False,
                       thread_count=-1,
                       verbose=False)

Parameters

Parameter Possible types Description Default value
data catboost.Pool

The dataset for feature importance calculation.

The required dataset depends on the selected feature importance calculation type (specified in the type parameter):

  • PredictionValuesChange — Either None or the same dataset that was used for training if the model does not contain information regarding the weight of leaves. All models trained with CatBoost version 0.9 or higher contain leaf weight information by default.
  • LossFunctionChange  — Any dataset. Feature importances are calculated on a subset for large datasets.
  • PredictionDiff — A list of object pairs.

Required parameter for the LossFunctionChange and ShapValues type of feature importances and in case the model does not contain information regarding the weight of leaves.

None otherwise.

type

Alias: fstr_type (deprecated, use type instead)

Note.

It is recommended to use EFStrType for this parameter.

The type of feature importance to calculate.

Possible values:
  • FeatureImportance: Equal to PredictionValuesChange for non-ranking metrics and LossFunctionChange for ranking metrics (the value is determined automatically).

  • ShapValues: A vector with contributions of each feature to the prediction for every input object and the expected value of the model prediction for the object (average prediction given no knowledge about the object).
  • Interaction: The value of the feature interaction strength for each pair of features.

  • PredictionDiff: A vector with contributions of each feature to the RawFormulaVal difference for each pair of objects.
FeatureImportance
prettified bool
Return the feature importances as a list of the following pairs sorted by feature importance:
(feature_id, feature importance)
Should be used if one of the following values of the typeparameter is selected: