class_docstr: Selects useful features.
  
  Several strategies are possible (filter and wrapper methods).
  Works for classification problems only (multiclass or binary).
  
  Parameters
  ----------
  strategy : str, defaut = "l1"
      The strategy to select features.
      Available strategies = {"variance", "l1", "rf_feature_importance"}
  
  threshold : float, defaut = 0.3
      The percentage of variable to discard according to the strategy.
      Must be between 0. and 1.
class_docstr_tok: ["Selects","useful","features",".","Several","strategies","are","possible","(","filter","and","wrapper","methods",")",".","Works","for","classification","problems","only","(","multiclass","or","binary",")",".","Parameters","--","--","--","--","--","strategy",":","str",",","defaut","=","``","l1","''","The","strategy","to","select","features",".","Available","strategies","=","{","``","variance","''",",","``","l1","''",",","``","rf_feature_importance","''","}","threshold",":","float",",","defaut","=","0.3","The","percentage","of","variable","to","discard","according","to","the","strategy",".","Must","be","between","0.","and","1","."]
docstr: Fits Clf_feature_selector
  
  Parameters
  ----------
  df_train : pandas dataframe of shape = (n_train, n_features)
      The train dataset with numerical features and no NA
  
  y_train : pandas series of shape = (n_train, )
      The target for classification task. Must be encoded.
  
  Returns
  -------
  object
      self
docstr_tok: ["Fits","Clf_feature_selector","Parameters","--","--","--","--","--","df_train",":","pandas","dataframe","of","shape","=","(","n_train",",","n_features",")","The","train","dataset","with","numerical","features","and","no","NA","y_train",":","pandas","series","of","shape","=","(","n_train",",",")","The","target","for","classification","task",".","Must","be","encoded",".","Returns","--","--","--","-","object","self"]
code: def fit(self, df_train, y_train):
      """Fits Clf_feature_selector
  
      Parameters
      ----------
      df_train : pandas dataframe of shape = (n_train, n_features)
          The train dataset with numerical features and no NA
  
      y_train : pandas series of shape = (n_train, )
          The target for classification task. Must be encoded.
  
      Returns
      -------
      object
          self
      """
  
      # sanity checks
      if (type(df_train) != pd.SparseDataFrame) and (
          type(df_train) != pd.DataFrame
      ):
          raise ValueError("df_train must be a DataFrame")
  
      if type(y_train) != pd.core.series.Series:
          raise ValueError("y_train must be a Series")
  
      if self.strategy == "variance":
          coef = df_train.std()
          abstract_threshold = np.percentile(
              coef, 100.0 * self.threshold
          )
          self.__to_discard = coef[coef < abstract_threshold].index
          self.__fitOK = True
  
      elif self.strategy == "l1":
          model = LogisticRegression(
              C=0.01,
              penalty="l1",
              solver="saga",
              n_jobs=-1,
              random_state=0,
          )  # to be tuned
          model.fit(df_train, y_train)
          coef = np.mean(np.abs(model.coef_), axis=0)
          abstract_threshold = np.percentile(
              coef, 100.0 * self.threshold
          )
          self.__to_discard = df_train.columns[
              coef < abstract_threshold
          ]
          self.__fitOK = True
  
      elif self.strategy == "rf_feature_importance":
          model = RandomForestClassifier(
              n_estimators=50, n_jobs=-1, random_state=0
          )  # to be tuned
          model.fit(df_train, y_train)
          coef = model.feature_importances_
          abstract_threshold = np.percentile(
              coef, 100.0 * self.threshold
          )
          self.__to_discard = df_train.columns[
              coef < abstract_threshold
          ]
          self.__fitOK = True
  
      else:
          raise ValueError(
              "Strategy invalid. Please choose between "
              "'variance', 'l1' or 'rf_feature_importance'"
          )
  
      return self
  
file_path: MLBox/mlbox/model/classification/feature_selector.py
imports: import numpy
  import pandas
  from sklearn.linear_model import LogisticRegression
  from sklearn.ensemble import RandomForestClassifier
  import warnings
label_desc: Use image node_id 4 for calling the Clf_feature_selector obj's underlying member method code with example usage: obj.fit(df_train, y_train) and returns: self