class_docstr: Transformer mixin selecting features based on importance weights.
  
  This implementation can be mixin on any estimator that exposes a
  ``feature_importances_`` or ``coef_`` attribute to evaluate the relative
  importance of individual features for feature selection.
class_docstr_tok: ["Transformer","mixin","selecting","features","based","on","importance","weights",".","This","implementation","can","be","mixin","on","any","estimator","that","exposes","a","``","feature_importances_","``","or","``","coef_","``","attribute","to","evaluate","the","relative","importance","of","individual","features","for","feature","selection","."]
docstr: Reduce X to its most important features.
  
  Uses ``coef_`` or ``feature_importances_`` to determine the most
  important features.  For models with a ``coef_`` for each class, the
  absolute sum over the classes is used.
  
  Parameters
  ----------
  X : array or scipy sparse matrix of shape [n_samples, n_features]
      The input samples.
  
  threshold : string, float or None, optional (default=None)
      The threshold value to use for feature selection. Features whose
      importance is greater or equal are kept while the others are
      discarded. If "median" (resp. "mean"), then the threshold value is
      the median (resp. the mean) of the feature importances. A scaling
      factor (e.g., "1.25*mean") may also be used. If None and if
      available, the object attribute ``threshold`` is used. Otherwise,
      "mean" is used by default.
  
  Returns
  -------
  X_r : array of shape [n_samples, n_selected_features]
      The input samples with only the selected features.
docstr_tok: ["Reduce","X","to","its","most","important","features",".","Uses","``","coef_","``","or","``","feature_importances_","``","to","determine","the","most","important","features",".","For","models","with","a","``","coef_","``","for","each","class",",","the","absolute","sum","over","the","classes","is","used",".","Parameters","--","--","--","--","--","X",":","array","or","scipy","sparse","matrix","of","shape","[","n_samples",",","n_features","]","The","input","samples",".","threshold",":","string",",","float","or","None",",","optional","(","default=None",")","The","threshold","value","to","use","for","feature","selection",".","Features","whose","importance","is","greater","or","equal","are","kept","while","the","others","are","discarded",".","If","``","median","''","(","resp",".","``","mean","''",")",",","then","the","threshold","value","is","the","median","(","resp",".","the","mean",")","of","the","feature","importances",".","A","scaling","factor","(","e.g.",",","``","1.25","*","mean","''",")","may","also","be","used",".","If","None","and","if","available",",","the","object","attribute","``","threshold","``","is","used",".","Otherwise",",","``","mean","''","is","used","by","default",".","Returns","--","--","--","-","X_r",":","array","of","shape","[","n_samples",",","n_selected_features","]","The","input","samples","with","only","the","selected","features","."]
code: def transform(self, X, threshold=None):
      """Reduce X to its most important features.
  
      Uses ``coef_`` or ``feature_importances_`` to determine the most
      important features.  For models with a ``coef_`` for each class, the
      absolute sum over the classes is used.
  
      Parameters
      ----------
      X : array or scipy sparse matrix of shape [n_samples, n_features]
          The input samples.
  
      threshold : string, float or None, optional (default=None)
          The threshold value to use for feature selection. Features whose
          importance is greater or equal are kept while the others are
          discarded. If "median" (resp. "mean"), then the threshold value is
          the median (resp. the mean) of the feature importances. A scaling
          factor (e.g., "1.25*mean") may also be used. If None and if
          available, the object attribute ``threshold`` is used. Otherwise,
          "mean" is used by default.
  
      Returns
      -------
      X_r : array of shape [n_samples, n_selected_features]
          The input samples with only the selected features.
      """
      check_is_fitted(
          self, ("coef_", "feature_importances_"), all_or_any=any
      )
  
      X = check_array(X, "csc")
      importances = _get_feature_importances(self)
      if len(importances) != X.shape[1]:
          raise ValueError(
              "X has different number of features than"
              " during model fitting."
          )
  
      if threshold is None:
          threshold = getattr(self, "threshold", None)
      threshold = _calculate_threshold(self, importances, threshold)
  
      # Selection
      try:
          mask = importances >= threshold
      except TypeError:
          # Fails in Python 3.x when threshold is str;
          # result is array of True
          raise ValueError(
              "Invalid threshold: all features are discarded."
          )
  
      if np.any(mask):
          mask = safe_mask(X, mask)
          return X[:, mask]
      else:
          raise ValueError(
              "Invalid threshold: all features are discarded."
          )
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/feature_selection/from_model.py
imports: import numpy
  from .base import SelectorMixin
  from ..base import TransformerMixin, BaseEstimator, clone
  from ..externals import six
  from ..utils import safe_mask, check_array, deprecated
  from ..utils.validation import check_is_fitted
  from ..exceptions import NotFittedError
label_desc: Use image node_id 1 for calling the _LearntSelectorMixin obj's underlying member method code with example usage: obj.transform(X, threshold) and returns: X