class_docstr: SmartCorrelatedSelection() finds groups of correlated features and then selects,
  from each group, a feature following certain criteria:
  
  - Feature with least missing values
  - Feature with most unique values
  - Feature with highest variance
  - Feature with highest importance according to an estimator
  
  SmartCorrelatedSelection() returns a dataframe containing from each group of
  correlated features, the selected variable, plus all original features that were
  not correlated to any other.
  
  Correlation is calculated with `pandas.corr()`.
  
  SmartCorrelatedSelection() works only with numerical variables. Categorical
  variables will need to be encoded to numerical or will be excluded from the
  analysis.
  
  More details in the :ref:`User Guide <smart_correlation>`.
  
  Parameters
  ----------
  {variables}
  
  method: string or callable, default='pearson'
      Can take 'pearson', 'spearman', 'kendall' or callable. It refers to the
      correlation method to be used to identify the correlated features.
  
      - 'pearson': standard correlation coefficient
      - 'kendall': Kendall Tau correlation coefficient
      - 'spearman': Spearman rank correlation
      - callable: callable with input two 1d ndarrays and returning a float.
  
      For more details on this parameter visit the `pandas.corr()` documentation.
  
  threshold: float, default=0.8
      The correlation threshold above which a feature will be deemed correlated with
      another one and removed from the dataset.
  
  {missing_values}
  
  selection_method: str, default= "missing_values"
      Takes the values "missing_values", "cardinality", "variance" and
      "model_performance".
  
      **"missing_values"**: keeps the feature from the correlated group with least
      missing observations
  
      **"cardinality"**: keeps the feature from the correlated group with the highest
      cardinality.
  
      **"variance"**: keeps the feature from the correlated group with the highest
      variance.
  
      **"model_performance"**: trains a machine learning model using the correlated
      feature group and retains the feature with the highest importance.
  
  {estimator}
  
  {scoring}
  
  {cv}
  
  {confirm_variables}
  
  Attributes
  ----------
  correlated_feature_sets_:
      Groups of correlated features. Each list is a group of correlated features.
  
  features_to_drop_:
      The correlated features to remove from the dataset.
  
  {variables_}
  
  {feature_names_in_}
  
  {n_features_in_}
  
  Methods
  -------
  fit:
      Find best feature from each correlated group.
  
  {fit_transform}
  
  {get_support}
  
  transform:
      Return selected features.
  
  Notes
  -----
  For brute-force correlation selection, check Feature-engine's
  DropCorrelatedFeatures().
  
  See Also
  --------
  pandas.corr
  feature_engine.selection.DropCorrelatedFeatures
class_docstr_tok: ["SmartCorrelatedSelection","(",")","finds","groups","of","correlated","features","and","then","selects",",","from","each","group",",","a","feature","following","certain","criteria",":","-","Feature","with","least","missing","values","-","Feature","with","most","unique","values","-","Feature","with","highest","variance","-","Feature","with","highest","importance","according","to","an","estimator","SmartCorrelatedSelection","(",")","returns","a","dataframe","containing","from","each","group","of","correlated","features",",","the","selected","variable",",","plus","all","original","features","that","were","not","correlated","to","any","other",".","Correlation","is","calculated","with","`","pandas.corr","(",")","`",".","SmartCorrelatedSelection","(",")","works","only","with","numerical","variables",".","Categorical","variables","will","need","to","be","encoded","to","numerical","or","will","be","excluded","from","the","analysis",".","More","details","in","the",":","ref",":","`","User","Guide","<","smart_correlation",">","`",".","Parameters","--","--","--","--","--","{","variables","}","method",":","string","or","callable",",","default='pearson'","Can","take","'pearson","'",",","'spearman","'",",","'kendall","'","or","callable",".","It","refers","to","the","correlation","method","to","be","used","to","identify","the","correlated","features",".","-","'pearson","'",":","standard","correlation","coefficient","-","'kendall","'",":","Kendall","Tau","correlation","coefficient","-","'spearman","'",":","Spearman","rank","correlation","-","callable",":","callable","with","input","two","1d","ndarrays","and","returning","a","float",".","For","more","details","on","this","parameter","visit","the","`","pandas.corr","(",")","`","documentation",".","threshold",":","float",",","default=0.8","The","correlation","threshold","above","which","a","feature","will","be","deemed","correlated","with","another","one","and","removed","from","the","dataset",".","{","missing_values","}","selection_method",":","str",",","default=","``","missing_values","''","Takes","the","values","``","missing_values","''",",","``","cardinality","''",",","``","variance","''","and","``","model_performance","''",".","*","*","''","missing_values","''","*","*",":","keeps","the","feature","from","the","correlated","group","with","least","missing","observations","*","*","''","cardinality","''","*","*",":","keeps","the","feature","from","the","correlated","group","with","the","highest","cardinality",".","*","*","''","variance","''","*","*",":","keeps","the","feature","from","the","correlated","group","with","the","highest","variance",".","*","*","''","model_performance","''","*","*",":","trains","a","machine","learning","model","using","the","correlated","feature","group","and","retains","the","feature","with","the","highest","importance",".","{","estimator","}","{","scoring","}","{","cv","}","{","confirm_variables","}","Attributes","--","--","--","--","--","correlated_feature_sets_",":","Groups","of","correlated","features",".","Each","list","is","a","group","of","correlated","features",".","features_to_drop_",":","The","correlated","features","to","remove","from","the","dataset",".","{","variables_","}","{","feature_names_in_","}","{","n_features_in_","}","Methods","--","--","--","-","fit",":","Find","best","feature","from","each","correlated","group",".","{","fit_transform","}","{","get_support","}","transform",":","Return","selected","features",".","Notes","--","--","-","For","brute-force","correlation","selection",",","check","Feature-engine's","DropCorrelatedFeatures","(",")",".","See","Also","--","--","--","--","pandas.corr","feature_engine.selection.DropCorrelatedFeatures"]
code: def __init__(
      self,
      variables: Variables = None,
      method: str = "pearson",
      threshold: float = 0.8,
      missing_values: str = "ignore",
      selection_method: str = "missing_values",
      estimator=None,
      scoring: str = "roc_auc",
      cv=3,
      confirm_variables: bool = False,
  ):
      if (
          not isinstance(threshold, float)
          or threshold < 0
          or threshold > 1
      ):
          raise ValueError("threshold must be a float between 0 and 1")
  
      if missing_values not in ["raise", "ignore"]:
          raise ValueError(
              "missing_values takes only values 'raise' or 'ignore'."
          )
  
      if selection_method not in [
          "missing_values",
          "cardinality",
          "variance",
          "model_performance",
      ]:
          raise ValueError(
              "selection_method takes only values 'missing_values', 'cardinality', "
              "'variance' or 'model_performance'."
          )
  
      if selection_method == "model_performance" and estimator is None:
          raise ValueError(
              "Please provide an estimator, e.g., "
              "RandomForestClassifier or select another "
              "selection_method"
          )
  
      if (
          selection_method == "missing_values"
          and missing_values == "raise"
      ):
          raise ValueError(
              "To select the variables with least missing values, we "
              "need to allow this transformer to contemplate variables "
              "with NaN by setting missing_values to 'ignore."
          )
  
      super().__init__(confirm_variables)
  
      self.variables = _check_init_parameter_variables(variables)
      self.method = method
      self.threshold = threshold
      self.missing_values = missing_values
      self.selection_method = selection_method
      self.estimator = estimator
      self.scoring = scoring
      self.cv = cv
  
file_path: feature_engine/feature_engine/selection/smart_correlation_selection.py
imports: from typing import List, Union
  import pandas
  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._variable_handling.init_parameter_checks import _check_init_parameter_variables
  from feature_engine._variable_handling.variable_type_selection import _find_or_check_numerical_variables
  from feature_engine.dataframe_checks import _check_contains_inf, _check_contains_na, check_X
  from feature_engine.selection._docstring import _cv_docstring, _estimator_docstring, _get_support_docstring, _missing_values_docstring, _scoring_docstring, _variables_attribute_docstring, _variables_numerical_docstring
  from feature_engine.selection.base_selector import BaseSelector
label_desc: Use image node_id 1 to create a new SmartCorrelatedSelection object from inherited base classes: BaseSelector with example: obj = SmartCorrelatedSelection(variables, method, threshold, missing_values, selection_method, estimator, scoring, cv, confirm_variables)