MCPcopy Create free account
hub / github.com/catboost/catboost / get_feature_importance

Method get_feature_importance

catboost/python-package/catboost/core.py:3385–3601  ·  view source on GitHub ↗

Parameters ---------- data : Data to get feature importance. If type in ('LossFunctionChange', 'ShapValues', 'ShapInteractionValues') data must of Pool type. For every object in this dataset feature importances will be calculated.

(self, data=None, type=EFstrType.FeatureImportance, prettified=False,
                               thread_count=-1, verbose=False, fstr_type=None, shap_mode="Auto",
                               model_output="Raw", interaction_indices=None, shap_calc_type="Regular",
                               reference_data=None, sage_n_samples=128, sage_batch_size=512,
                               sage_detect_convergence=True, log_cout=None, log_cerr=None)

Source from the content-addressed store, hash-verified

3383 return np.array(getattr(self, "_prediction_values_change", None))
3384
3385 def get_feature_importance(self, data=None, type=EFstrType.FeatureImportance, prettified=False,
3386 thread_count=-1, verbose=False, fstr_type=None, shap_mode="Auto",
3387 model_output="Raw", interaction_indices=None, shap_calc_type="Regular",
3388 reference_data=None, sage_n_samples=128, sage_batch_size=512,
3389 sage_detect_convergence=True, log_cout=None, log_cerr=None):
3390 """
3391 Parameters
3392 ----------
3393 data :
3394 Data to get feature importance.
3395 If type in ('LossFunctionChange', 'ShapValues', 'ShapInteractionValues') data must of Pool type.
3396 For every object in this dataset feature importances will be calculated.
3397 if type == 'SageValues' data must of Pool type.
3398 For every feature in this dataset importance will be calculated.
3399 If type == 'PredictionValuesChange', data is None or a dataset of Pool type
3400 Dataset specification is needed only in case if the model does not contain leaf weight information (trained with CatBoost v < 0.9).
3401 If type == 'PredictionDiff' data must contain a matrix of feature values of shape (2, n_features).
3402 Possible types are catboost.Pool or list of lists or numpy.ndarray or pandas.DataFrame or pandas.Series
3403 or polars.DataFrame or catboost.FeaturesData or pandas.SparseDataFrame or scipy.sparse.spmatrix
3404 If type == 'FeatureImportance'
3405 See 'PredictionValuesChange' for non-ranking metrics and 'LossFunctionChange' for ranking metrics.
3406 If type == 'Interaction'
3407 This parameter is not used.
3408
3409 type : EFstrType or string (converted to EFstrType), optional
3410 (default=EFstrType.FeatureImportance)
3411 Possible values:
3412 - PredictionValuesChange
3413 Calculate score for every feature.
3414 - LossFunctionChange
3415 Calculate score for every feature by loss.
3416 - FeatureImportance
3417 PredictionValuesChange for non-ranking metrics and LossFunctionChange for ranking metrics
3418 - ShapValues
3419 Calculate SHAP Values for every object.
3420 - ShapInteractionValues
3421 Calculate SHAP Interaction Values between each pair of features for every object
3422 - Interaction
3423 Calculate pairwise score between every feature.
3424 - PredictionDiff
3425 Calculate most important features explaining difference in predictions for a pair of documents.
3426 - SageValues
3427 Calculate SAGE value for every feature
3428
3429 prettified : bool, optional (default=False)
3430 change returned data format to the list of (feature_id, importance) pairs sorted by importance
3431
3432 thread_count : int, optional (default=-1)
3433 Number of threads.
3434 If -1, then the number of threads is set to the number of CPU cores.
3435
3436 verbose : bool or int
3437 If False, then evaluation is not logged. If True, then each possible iteration is logged.
3438 If a positive integer, then it stands for the size of batch N. After processing each batch, print progress
3439 and remaining time.
3440
3441 fstr_type : string, deprecated, use type instead
3442

Callers 15

test_shapFunction · 0.95
test_shap_verboseFunction · 0.95
_fitMethod · 0.95
prediction_values_changeFunction · 0.80
loss_function_changeFunction · 0.80
interactionFunction · 0.80
shap_valuesFunction · 0.80
prediction_diffFunction · 0.80
shap_interaction_valuesFunction · 0.80

Calls 10

isinstanceFunction · 0.85
enum_from_enum_or_strFunction · 0.85
setattrFunction · 0.85
_calc_fstrMethod · 0.80
log_fixupFunction · 0.70
CatBoostErrorClass · 0.50
intFunction · 0.50
formatMethod · 0.45
arrayMethod · 0.45