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

Method select_features

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

Select best features from pool according to loss value. Parameters ---------- X : catboost.Pool or list or numpy.ndarray or pandas.DataFrame or pandas.Series or polars.DataFrame If not catboost.Pool, 2 dimensional Feature matrix or string - file with dat

(self, X, y=None, eval_set=None, features_for_select=None, num_features_to_select=None,
                        algorithm=None, steps=None, shap_calc_type=None, train_final_model=True, verbose=None,
                        logging_level=None, plot=False, plot_file=None, log_cout=None, log_cerr=None,
                        grouping=None, features_tags_for_select=None, num_features_tags_to_select=None)

Source from the content-addressed store, hash-verified

4633 )
4634
4635 def select_features(self, X, y=None, eval_set=None, features_for_select=None, num_features_to_select=None,
4636 algorithm=None, steps=None, shap_calc_type=None, train_final_model=True, verbose=None,
4637 logging_level=None, plot=False, plot_file=None, log_cout=None, log_cerr=None,
4638 grouping=None, features_tags_for_select=None, num_features_tags_to_select=None):
4639 """
4640 Select best features from pool according to loss value.
4641
4642 Parameters
4643 ----------
4644 X : catboost.Pool or list or numpy.ndarray or pandas.DataFrame or pandas.Series or polars.DataFrame
4645 If not catboost.Pool, 2 dimensional Feature matrix or string - file with dataset.
4646
4647 y : list or numpy.ndarray or pandas.DataFrame or pandas.Series or polars.DataFrame or polars.Series, optional (default=None)
4648 Labels of the training data.
4649 If not None, can be a single- or two- dimensional array with either:
4650 - numerical values - for regression (including multiregression), ranking and binary classification problems
4651 - class labels (boolean, integer or string) - for classification (including multiclassification) problems
4652 Use only if X is not catboost.Pool and does not point to a file.
4653
4654 eval_set : catboost.Pool or list of catboost.Pool or tuple (X, y) or list [(X, y)], optional (default=None)
4655 Validation dataset or datasets for metrics calculation and possibly early stopping.
4656
4657 features_for_select : str or list of feature indices, names or ranges
4658 (for grouping = Individual)
4659 Which features should participate in the selection.
4660 Format examples:
4661 - [0, 2, 3, 4, 17]
4662 - [0, "2-4", 17] (both ends in ranges are inclusive)
4663 - "0,2-4,20"
4664 - ["Name0", "Name2", "Name3", "Name4", "Name20"]
4665
4666 num_features_to_select : positive int
4667 (for grouping = Individual)
4668 How many features to select from features_for_select.
4669
4670 algorithm : EFeaturesSelectionAlgorithm or string, optional (default=RecursiveByShapValues)
4671 Which algorithm to use for features selection.
4672 Possible values:
4673 - RecursiveByPredictionValuesChange
4674 Use prediction values change as feature strength, eliminate batch of features at once.
4675 - RecursiveByLossFunctionChange
4676 Use loss function change as feature strength, eliminate batch of features at each step.
4677 - RecursiveByShapValues
4678 Use shap values to estimate loss function change, eliminate features one by one.
4679
4680 steps : positive int, optional (default=1)
4681 How many steps should be performed. In other words, how many times a full model will be trained.
4682 More steps give more accurate results.
4683
4684 shap_calc_type : EShapCalcType or string, optional (default=Regular)
4685 Which method to use for calculation of shap values.
4686 Possible values:
4687 - Regular
4688 Calculate regular SHAP values
4689 - Approximate
4690 Calculate approximate SHAP values
4691 - Exact
4692 Calculate exact SHAP values

Calls 15

_prepare_train_paramsMethod · 0.95
isinstanceFunction · 0.85
enum_from_enum_or_strFunction · 0.85
mapClass · 0.85
lenFunction · 0.85
_get_train_dirFunction · 0.85
create_dir_if_not_existFunction · 0.85
plot_wrapperFunction · 0.85
is_fittedMethod · 0.80
log_fixupFunction · 0.70