ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.2 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://catboost.ai/docs/en/concepts/python-reference_catboostclassifier_get_feature_importance |
| Last Crawled | 2026-04-04 06:51:47 (4 days ago) |
| First Indexed | 2024-11-18 16:12:15 (1 year ago) |
| HTTP Status Code | 200 |
| Meta Title | get_feature_importance | CatBoost |
| Meta Description | Calculate and return the feature importances. Method call format. |
| Meta Canonical | null |
| Boilerpipe Text | Calculate and return the
feature importances
.
Method call format
get_feature_importance(data=
None
,
reference_data=
None
,
type
=EFstrType.FeatureImportance,
prettified=
False
,
thread_count=-
1
,
verbose=
False
,
log_cout=sys.stdout,
log_cerr=sys.stderr)
Parameters
data
Description
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.
Possible types
catboost.Pool
Default value
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.
reference_data
Description
Reference data for Independent Tree SHAP values from
Explainable AI for Trees: From Local Explanations to Global Understanding
. If
type
is
ShapValues
and
reference_data
is not
None
, then Independent Tree SHAP values are calculated.
Possible types
catboost.Pool
Default value
None
type
Alias:
fstr_type
(deprecated, use
type
instead)
Description
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
v
v
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.
Possible types
string
EFStrType
Note
It is recommended to use EFStrType for this parameter.
Default value
FeatureImportance
prettified
Description
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
type
parameter is selected:
PredictionValuesChange
PredictionValuesChange
Possible types
bool
Default value
False
thread_count
Description
The number of threads to use for operation.
Optimizes the speed of execution. This parameter doesn't affect results.
Possible types
int
Default value
-1 (the number of threads is equal to the number of processor cores)
verbose
Description
The purpose of this parameter depends on the type of the given value:
bool — Output progress to stdout.
Works with the
ShapValues
type of feature importance calculation.
int — The logging period.
Possible types
bool
int
Default value
False
log_cout
Output stream or callback for logging.
Possible types
callable Python object
python object providing the
write()
method
Default value
sys.stdout
log_cerr
Error stream or callback for logging.
Possible types
callable Python object
python object providing the
write()
method
Default value
sys.stderr
Type of return value
Depends on the selected feature strength calculation method:
PredictionValuesChange, LossFunctionChange or PredictionValuesChange with the
prettified
parameter set to
False
: a list of length
[n_features]
with float feature importances values for each feature
PredictionValuesChange or LossFunctionChange with the
prettified
parameter set to
True
: a list of length
[n_features]
with
(feature_id (string), feature_importance (float))
pairs, sorted by feature importance values in descending order
ShapValues: np.array of shape
(n_objects, n_features + 1)
with float ShapValues for each
(object, feature)
Interaction: list of length [ n_features] of three element lists of
(first_feature_index, second_feature_index, interaction_score (float)) |
| Markdown | [](https://catboost.ai/ "CatBoost")
- Installation
- [Overview](https://catboost.ai/docs/en/concepts/en/concepts/installation)
- Python package installation
- CatBoost for Apache Spark installation
- R package installation
- Command-line version binary
- Build from source
- Key Features
- Training parameters
- Python package
- [Quick start](https://catboost.ai/docs/en/concepts/en/concepts/python-quickstart)
- CatBoost
- CatBoostClassifier
- [Overview](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier)
- [fit](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_fit)
- [predict](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_predict)
- [predict\_proba](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_predict_proba)
- [Attributes](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_attributes)
- [calc\_leaf\_indexes](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboost_calc_leaf_indexes)
- [calc\_feature\_statistics](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_calc_feature_statistics)
- [compare](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_modelcompare)
- [copy](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_copy)
- [eval\_metrics](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_eval-metrics)
- [get\_all\_params](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_all_params)
- [get\_best\_iteration](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_best_iteration)
- [get\_best\_score](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_best_score)
- [get\_borders](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_borders)
- [get\_evals\_result](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_evals_result)
- [get\_feature\_importance](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance)
- [get\_metadata](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_metadata)
- [get\_object\_importance](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_object_importance)
- [get\_param](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_param)
- [get\_params](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_params)
- [get\_probability\_threshold](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_probability_threshold)
- [get\_scale\_and\_bias](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_scale_and_bias)
- [get\_test\_eval](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_test_eval)
- [grid\_search](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_grid_search)
- [is\_fitted](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_is_fitted)
- [load\_model](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_load_model)
- [plot\_predictions](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_plot_predictions)
- [plot\_tree](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_plot_tree)
- [randomized\_search](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_randomized_search)
- [save\_borders](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_save_borders)
- [save\_model](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_save_model)
- [score](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_score)
- [select\_features](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_select_features)
- [set\_feature\_names](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_set_feature_names)
- [set\_params](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_set_params)
- [set\_probability\_threshold](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_set_probability_threshold)
- [set\_scale\_and\_bias](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_set_scale_and_bias)
- [shrink](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_shrink)
- [staged\_predict](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_staged_predict)
- [staged\_predict\_proba](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_staged_predict_proba)
- CatBoostRanker
- CatBoostRegressor
- [cv](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_cv)
- datasets
- FeaturesData
- MetricVisualizer
- Pool
- [sample\_gaussian\_process](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_sample_gaussian_process)
- [sum\_models](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_sum_models)
- [to\_classifier](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_to_classifier)
- [to\_regressor](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_to_regressor)
- [train](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_train)
- Text processing
- utils
- [Usage examples](https://catboost.ai/docs/en/concepts/en/concepts/python-usages-examples)
- CatBoost for Apache Spark
- R package
- Command-line version
- Applying models
- Objectives and metrics
- Model analysis
- Data format description
- [Parameter tuning](https://catboost.ai/docs/en/concepts/en/concepts/parameter-tuning)
- [Speeding up the training](https://catboost.ai/docs/en/concepts/en/concepts/speed-up-training)
- Data visualization
- Algorithm details
- [FAQ](https://catboost.ai/docs/en/concepts/en/concepts/faq)
- Educational materials
- [Development and contributions](https://catboost.ai/docs/en/concepts/en/concepts/development-and-contributions)
- [Contacts](https://catboost.ai/docs/en/concepts/en/concepts/contacts)
get\_feature\_importance
## In this article:
- [Method call format](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#call-format)
- [Parameters](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#parameters)
- [data](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#data)
- [reference\_data](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#reference_data)
- [type](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#type)
- [prettified](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#prettified)
- [thread\_count](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#thread_count)
- [verbose](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#verbose)
- [log\_cout](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#log_cout)
- [log\_cerr](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#log_cerr)
- [Type of return value](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#output-format)
1. Python package
2. [CatBoostClassifier](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier)
3. get\_feature\_importance
# get\_feature\_importance
- [Method call format](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#call-format)
- [Parameters](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#parameters)
- [data](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#data)
- [reference\_data](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#reference_data)
- [type](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#type)
- [prettified](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#prettified)
- [thread\_count](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#thread_count)
- [verbose](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#verbose)
- [log\_cout](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#log_cout)
- [log\_cerr](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#log_cerr)
- [Type of return value](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_feature_importance#output-format)
Calculate and return the [feature importances](https://catboost.ai/docs/en/concepts/en/concepts/fstr).
## Method call format
```
get_feature_importance(data=None,
reference_data=None,
type=EFstrType.FeatureImportance,
prettified=False,
thread_count=-1,
verbose=False,
log_cout=sys.stdout,
log_cerr=sys.stderr)
```
## Parameters
### data
#### Description
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.
**Possible types**
catboost.Pool
**Default value**
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.
### reference\_data
#### Description
Reference data for Independent Tree SHAP values from [Explainable AI for Trees: From Local Explanations to Global Understanding](https://arxiv.org/abs/1905.04610v1). If `type` is [`ShapValues`](https://catboost.ai/docs/en/concepts/en/concepts/shap-values) and `reference_data` is not `None`, then Independent Tree SHAP values are calculated.
**Possible types**
catboost.Pool
**Default value**
None
### type
*Alias:*`fstr_type` (deprecated, use `type` instead)
#### Description
The type of feature importance to calculate.
Possible values:
- FeatureImportance: Equal to [PredictionValuesChange](https://catboost.ai/docs/en/concepts/en/concepts/fstr#regular-feature-importance) for non-ranking metrics and [LossFunctionChange](https://catboost.ai/docs/en/concepts/en/concepts/fstr#regular-feature-importances__lossfunctionchange) for ranking metrics (the value is determined automatically).
- [ShapValues](https://catboost.ai/docs/en/concepts/en/concepts/shap-values): A vector v v v 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](https://catboost.ai/docs/en/concepts/en/concepts/feature-interaction#feature-interaction-strength): 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.
**Possible types**
- string
- [EFStrType](https://catboost.ai/docs/en/concepts/en/concepts/python-efstr-type__desc)
Note
It is recommended to use EFStrType for this parameter.
**Default value**
FeatureImportance
### prettified
#### Description
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 `type`parameter is selected:
- PredictionValuesChange
- PredictionValuesChange
**Possible types**
bool
**Default value**
False
### thread\_count
#### Description
The number of threads to use for operation.
Optimizes the speed of execution. This parameter doesn't affect results.
**Possible types**
int
**Default value**
\-1 (the number of threads is equal to the number of processor cores)
### verbose
#### Description
The purpose of this parameter depends on the type of the given value:
- bool — Output progress to stdout.
Works with the [ShapValues](https://catboost.ai/docs/en/concepts/en/concepts/shap-values) type of feature importance calculation.
- int — The logging period.
**Possible types**
- bool
- int
**Default value**
False
### log\_cout
Output stream or callback for logging.
**Possible types**
- callable Python object
- python object providing the `write()` method
**Default value**
sys.stdout
### log\_cerr
Error stream or callback for logging.
**Possible types**
- callable Python object
- python object providing the `write()` method
**Default value**
sys.stderr
## Type of return value
Depends on the selected feature strength calculation method:
- PredictionValuesChange, LossFunctionChange or PredictionValuesChange with the `prettified` parameter set to "False": a list of length `[n_features]` with float feature importances values for each feature
- PredictionValuesChange or LossFunctionChange with the `prettified` parameter set to "True": a list of length `[n_features]` with `(feature_id (string), feature_importance (float))` pairs, sorted by feature importance values in descending order
- ShapValues: np.array of shape `(n_objects, n_features + 1)` with float ShapValues for each `(object, feature)`
- Interaction: list of length \[ n\_features\] of three element lists of `(first_feature_index, second_feature_index, interaction_score (float))`
### Was the article helpful?
Yes
No
Previous
[get\_evals\_result](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_get_evals_result)
Next
[get\_metadata](https://catboost.ai/docs/en/concepts/en/concepts/python-reference_catboostclassifier_metadata)
 |
| Readable Markdown | Calculate and return the [feature importances](https://catboost.ai/docs/en/concepts/fstr).
## Method call format
```
get_feature_importance(data=None,
reference_data=None,
type=EFstrType.FeatureImportance,
prettified=False,
thread_count=-1,
verbose=False,
log_cout=sys.stdout,
log_cerr=sys.stderr)
```
## Parameters
### data
#### Description
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.
**Possible types**
catboost.Pool
**Default value**
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.
### reference\_data
#### Description
Reference data for Independent Tree SHAP values from [Explainable AI for Trees: From Local Explanations to Global Understanding](https://arxiv.org/abs/1905.04610v1). If `type` is [`ShapValues`](https://catboost.ai/docs/en/concepts/shap-values) and `reference_data` is not `None`, then Independent Tree SHAP values are calculated.
**Possible types**
catboost.Pool
**Default value**
None
### type
*Alias:*`fstr_type` (deprecated, use `type` instead)
#### Description
The type of feature importance to calculate.
Possible values:
- FeatureImportance: Equal to [PredictionValuesChange](https://catboost.ai/docs/en/concepts/fstr#regular-feature-importance) for non-ranking metrics and [LossFunctionChange](https://catboost.ai/docs/en/concepts/fstr#regular-feature-importances__lossfunctionchange) for ranking metrics (the value is determined automatically).
- [ShapValues](https://catboost.ai/docs/en/concepts/shap-values): A vector v v 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](https://catboost.ai/docs/en/concepts/feature-interaction#feature-interaction-strength): 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.
**Possible types**
- string
- [EFStrType](https://catboost.ai/docs/en/concepts/python-efstr-type__desc)
Note
It is recommended to use EFStrType for this parameter.
**Default value**
FeatureImportance
### prettified
#### Description
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 `type`parameter is selected:
- PredictionValuesChange
- PredictionValuesChange
**Possible types**
bool
**Default value**
False
### thread\_count
#### Description
The number of threads to use for operation.
Optimizes the speed of execution. This parameter doesn't affect results.
**Possible types**
int
**Default value**
\-1 (the number of threads is equal to the number of processor cores)
### verbose
#### Description
The purpose of this parameter depends on the type of the given value:
- bool — Output progress to stdout.
Works with the [ShapValues](https://catboost.ai/docs/en/concepts/shap-values) type of feature importance calculation.
- int — The logging period.
**Possible types**
- bool
- int
**Default value**
False
### log\_cout
Output stream or callback for logging.
**Possible types**
- callable Python object
- python object providing the `write()` method
**Default value**
sys.stdout
### log\_cerr
Error stream or callback for logging.
**Possible types**
- callable Python object
- python object providing the `write()` method
**Default value**
sys.stderr
## Type of return value
Depends on the selected feature strength calculation method:
- PredictionValuesChange, LossFunctionChange or PredictionValuesChange with the `prettified` parameter set to "False": a list of length `[n_features]` with float feature importances values for each feature
- PredictionValuesChange or LossFunctionChange with the `prettified` parameter set to "True": a list of length `[n_features]` with `(feature_id (string), feature_importance (float))` pairs, sorted by feature importance values in descending order
- ShapValues: np.array of shape `(n_objects, n_features + 1)` with float ShapValues for each `(object, feature)`
- Interaction: list of length \[ n\_features\] of three element lists of `(first_feature_index, second_feature_index, interaction_score (float))` |
| Shard | 169 (laksa) |
| Root Hash | 17435841955170310369 |
| Unparsed URL | ai,catboost!/docs/en/concepts/python-reference_catboostclassifier_get_feature_importance s443 |