class_docstr: SelectByTargetMeanPerformance() uses the mean value of the target per category or
  per interval(if the variable is numerical), as proxy for target estimation. With
  this proxy, the selector determines the performance of each feature based on a
  metric of choice, and then selects the features based on this performance value.
  
  SelectByTargetMeanPerformance() can evaluate numerical and categorical variables,
  without much prior manipulation. In other words, you don't need to encode the
  categorical variables or transform the numerical variables to assess their
  importance if you use this transformer.
  
  SelectByTargetMeanPerformance() requires that the dataset is complete, without
  missing data.
  
  SelectByTargetMeanPerformance() determines the performance of each variable with
  cross-validation. More specifically:
  
  For each categorical variable:
  
  1. Determines the mean target value per category in the training folds.
  
  2. Replaces the categories by the target mean values in the test folds.
  
  3. Determines the performance of the transformed variables in the test folds.
  
  
  For each numerical variable:
  
  1. Discretises the variable into intervals of equal width or equal frequency.
  
  2. Determines the mean value of the target per interval in the training folds.
  
  3. Replaces the intervals by the target mean values in the test fold.
  
  4. Determines the performance of the transformed variable in the test fold.
  
  
  Finally, it selects the features which performance is bigger than the indicated
  threshold. If the threshold if left to None, it selects features which performance
  is bigger than the mean performance of all features.
  
  All the steps are performed with cross-validation. That means, that intervals and
  target mean values per interval or category are determined in a certain portion of
  the data, and evaluated in a left-out sample. The performance metric per variable
  is the average across the cross-validation folds.
  
  More details in the :ref:`User Guide <target_mean_selection>`.
  
  Parameters
  ----------
  variables: list, default=None
      The list of variables to evaluate. If None, the transformer will evaluate all
      variables in the dataset (except datetime).
  
  bins: int, default = 5
      If the dataset contains numerical variables, the number of bins into which
      the values will be sorted.
  
  strategy: str, default = 'equal_width'
      Whether the bins should be of equal width ('equal_width') or equal frequency
      ('equal_frequency').
  
  {scoring}
  
  {threshold}
  
  {cv}
  
  regression: boolean, default=True
      Indicates whether the target is one for regression or a classification.
  
  {confirm_variables}
  
  Attributes
  ----------
  {variables_}
  
  feature_performance_:
      Dictionary with the performance of each feature.
  
  {features_to_drop_}
  
  {feature_names_in_}
  
  {n_features_in_}
  
  Methods
  -------
  {fit}
  
  {fit_transform}
  
  {get_support}
  
  {transform}
  
  Notes
  -----
  Replacing the categories or intervals by the target mean is the equivalent to
  target mean encoding.
  
  See Also
  --------
  feature_engine.encoding.MeanEncoder
  feature_engine.discretisation.EqualWidthDiscretiser
  feature_engine.discretisation.EqualFrequencyDiscretiser
  
  References
  ----------
  .. [1] Miller, et al. "Predicting customer behaviour: The University of Melbourne’s
      KDD Cup report". JMLR Workshop and Conference Proceeding. KDD 2009
      http://proceedings.mlr.press/v7/miller09/miller09.pdf
class_docstr_tok: ["SelectByTargetMeanPerformance","(",")","uses","the","mean","value","of","the","target","per","category","or","per","interval","(","if","the","variable","is","numerical",")",",","as","proxy","for","target","estimation",".","With","this","proxy",",","the","selector","determines","the","performance","of","each","feature","based","on","a","metric","of","choice",",","and","then","selects","the","features","based","on","this","performance","value",".","SelectByTargetMeanPerformance","(",")","can","evaluate","numerical","and","categorical","variables",",","without","much","prior","manipulation",".","In","other","words",",","you","do","n't","need","to","encode","the","categorical","variables","or","transform","the","numerical","variables","to","assess","their","importance","if","you","use","this","transformer",".","SelectByTargetMeanPerformance","(",")","requires","that","the","dataset","is","complete",",","without","missing","data",".","SelectByTargetMeanPerformance","(",")","determines","the","performance","of","each","variable","with","cross-validation",".","More","specifically",":","For","each","categorical","variable",":","1",".","Determines","the","mean","target","value","per","category","in","the","training","folds",".","2",".","Replaces","the","categories","by","the","target","mean","values","in","the","test","folds",".","3",".","Determines","the","performance","of","the","transformed","variables","in","the","test","folds",".","For","each","numerical","variable",":","1",".","Discretises","the","variable","into","intervals","of","equal","width","or","equal","frequency",".","2",".","Determines","the","mean","value","of","the","target","per","interval","in","the","training","folds",".","3",".","Replaces","the","intervals","by","the","target","mean","values","in","the","test","fold",".","4",".","Determines","the","performance","of","the","transformed","variable","in","the","test","fold",".","Finally",",","it","selects","the","features","which","performance","is","bigger","than","the","indicated","threshold",".","If","the","threshold","if","left","to","None",",","it","selects","features","which","performance","is","bigger","than","the","mean","performance","of","all","features",".","All","the","steps","are","performed","with","cross-validation",".","That","means",",","that","intervals","and","target","mean","values","per","interval","or","category","are","determined","in","a","certain","portion","of","the","data",",","and","evaluated","in","a","left-out","sample",".","The","performance","metric","per","variable","is","the","average","across","the","cross-validation","folds",".","More","details","in","the",":","ref",":","`","User","Guide","<","target_mean_selection",">","`",".","Parameters","--","--","--","--","--","variables",":","list",",","default=None","The","list","of","variables","to","evaluate",".","If","None",",","the","transformer","will","evaluate","all","variables","in","the","dataset","(","except","datetime",")",".","bins",":","int",",","default","=","5","If","the","dataset","contains","numerical","variables",",","the","number","of","bins","into","which","the","values","will","be","sorted",".","strategy",":","str",",","default","=","'equal_width'","Whether","the","bins","should","be","of","equal","width","(","'equal_width","'",")","or","equal","frequency","(","'equal_frequency","'",")",".","{","scoring","}","{","threshold","}","{","cv","}","regression",":","boolean",",","default=True","Indicates","whether","the","target","is","one","for","regression","or","a","classification",".","{","confirm_variables","}","Attributes","--","--","--","--","--","{","variables_","}","feature_performance_",":","Dictionary","with","the","performance","of","each","feature",".","{","features_to_drop_","}","{","feature_names_in_","}","{","n_features_in_","}","Methods","--","--","--","-","{","fit","}","{","fit_transform","}","{","get_support","}","{","transform","}","Notes","--","--","-","Replacing","the","categories","or","intervals","by","the","target","mean","is","the","equivalent","to","target","mean","encoding",".","See","Also","--","--","--","--","feature_engine.encoding.MeanEncoder","feature_engine.discretisation.EqualWidthDiscretiser","feature_engine.discretisation.EqualFrequencyDiscretiser","References","--","--","--","--","--","..","[","1","]","Miller",",","et","al",".","``","Predicting","customer","behaviour",":","The","University","of","Melbourne","\u2019","s","KDD","Cup","report","''",".","JMLR","Workshop","and","Conference","Proceeding",".","KDD","2009","http",":","\/\/proceedings.mlr.press\/v7\/miller09\/miller09.pdf"]
docstr: Find the important features.
  
  Parameters
  ----------
  X: pandas dataframe of shape = [n_samples, n_features]
     The input dataframe.
  
  y: array-like of shape (n_samples)
     Target variable. Required to train the estimator.
docstr_tok: ["Find","the","important","features",".","Parameters","--","--","--","--","--","X",":","pandas","dataframe","of","shape","=","[","n_samples",",","n_features","]","The","input","dataframe",".","y",":","array-like","of","shape","(","n_samples",")","Target","variable",".","Required","to","train","the","estimator","."]
code: def fit(self, X: pd.DataFrame, y: pd.Series):
      """
      Find the important features.
  
      Parameters
      ----------
      X: pandas dataframe of shape = [n_samples, n_features]
         The input dataframe.
  
      y: array-like of shape (n_samples)
         Target variable. Required to train the estimator.
      """
      # check input dataframe
      X, y = check_X_y(X, y)
  
      # If required exclude variables that are not in the input dataframe
      self._confirm_variables(X)
  
      # find all variables or check those entered are present in the dataframe
      self.variables_ = _find_all_variables(
          X, self.variables_, exclude_datetime=True
      )
  
      if len(self.variables_) == 1 and self.threshold is None:
          raise ValueError(
              "When evaluating a single feature you need to manually set a value "
              "for the threshold. "
              f"The transformer is evaluating the performance of {self.variables_} "
              f"and the threshold was left to {self.threshold} when initializing "
              f"the transformer."
          )
  
      # save input features
      self._get_feature_names_in(X)
  
      # set up the correct estimator
      if self.regression is True:
          est = TargetMeanRegressor(
              bins=self.bins,
              strategy=self.strategy,
          )
      else:
          est = TargetMeanClassifier(
              bins=self.bins,
              strategy=self.strategy,
          )
  
      self.feature_performance_ = {}
  
      for variable in self.variables_:
          # clone estimator
          estimator = clone(est)
  
          # set the estimator to evaluate the required variable
          estimator.set_params(variables=variable)
  
          model = cross_validate(
              estimator,
              X,
              y,
              cv=self.cv,
              scoring=self.scoring,
          )
  
          self.feature_performance_[variable] = model[
              "test_score"
          ].mean()
  
      # select features
      if not self.threshold:
          threshold = pd.Series(self.feature_performance_).mean()
      else:
          threshold = self.threshold
  
      self.features_to_drop_ = [
          f
          for f in self.variables_
          if self.feature_performance_[f] < threshold
      ]
  
      return self
  
imports: from typing import List, Union
  import pandas
  from sklearn.base import clone
  from sklearn.model_selection import cross_validate
  from feature_engine._docstrings.fit_attributes import _feature_names_in_docstring, _n_features_in_docstring
  from feature_engine._docstrings.methods import _fit_transform_docstring
  from feature_engine._docstrings.substitute import Substitution
  from feature_engine._prediction.target_mean_classifier import TargetMeanClassifier
  from feature_engine._prediction.target_mean_regressor import TargetMeanRegressor
  from feature_engine._variable_handling.init_parameter_checks import _check_init_parameter_variables
  from feature_engine._variable_handling.variable_type_selection import _find_all_variables
  from feature_engine.dataframe_checks import check_X_y
  from feature_engine.selection._docstring import _cv_docstring, _features_to_drop_docstring, _fit_docstring, _get_support_docstring, _scoring_docstring, _threshold_docstring, _transform_docstring, _variables_attribute_docstring
  from feature_engine.selection._selection_constants import _CLASSIFICATION_METRICS, _REGRESSION_METRICS
  from feature_engine.selection.base_selector import BaseSelector
  from feature_engine.tags import _return_tags
label_desc: Use image node_id 2 for calling the SelectByTargetMeanPerformance obj's underlying member method code with example usage: obj.fit(X, y) and returns: self