class_docstr: A class for feature importance methods.
class_docstr_tok: ["A","class","for","feature","importance","methods","."]
docstr: Rank features based on the chosen statistic of the interaction.
  
  Args:
      data (pd.Dataframe): DataFrame containing outcome, features, and experiment group
      features (list of string): list of feature names, that are columns in the data DataFrame
      y_name (string): name of the outcome variable
      method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'}
          The feature selection method to be used to rank the features.
          'F' for F-test
          'LR' for likelihood ratio test
          'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively
      experiment_group_column (string): the experiment column name in the DataFrame, which contains the treatment and control assignment label
      control_group (string): name for control group, value in the experiment group column
      treatment_group (string): name for treatment group, value in the experiment group column
      n_bins (int, optional): number of bins to be used for bin-based uplift filter methods
      null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If value is None and null is present then exception will be raised
      order (int): the order of feature to be evaluated with the treatment effect for F filter and LR filter, order takes 3 values: 1,2,3. order = 1 corresponds to linear importance of the feature, order=2 corresponds to quadratic and linear importance of the feature,
      order= 3 will calculate feature importance up to cubic forms.
      disp (bool): Set to True to print convergence messages for Logistic regression convergence in LR method.
  
  Returns:
      all_result : pd.DataFrame
          a data frame with following columns: ['method', 'feature', 'rank', 'score', 'p_value', 'misc']
docstr_tok: ["Rank","features","based","on","the","chosen","statistic","of","the","interaction",".","Args",":","data","(","pd.Dataframe",")",":","DataFrame","containing","outcome",",","features",",","and","experiment","group","features","(","list","of","string",")",":","list","of","feature","names",",","that","are","columns","in","the","data","DataFrame","y_name","(","string",")",":","name","of","the","outcome","variable","method","(","string",",","optional",",","default","=","'KL","'",")",":","taking","one","of","the","following","values","{","'","F","'",",","'LR","'",",","'KL","'",",","'ED","'",",","'Chi","'","}","The","feature","selection","method","to","be","used","to","rank","the","features",".","'","F","'","for","F-test","'LR","'","for","likelihood","ratio","test","'KL","'",",","'ED","'",",","'Chi","'","for","bin-based","uplift","filter","methods",",","KL","divergence",",","Euclidean","distance",",","Chi-Square","respectively","experiment_group_column","(","string",")",":","the","experiment","column","name","in","the","DataFrame",",","which","contains","the","treatment","and","control","assignment","label","control_group","(","string",")",":","name","for","control","group",",","value","in","the","experiment","group","column","treatment_group","(","string",")",":","name","for","treatment","group",",","value","in","the","experiment","group","column","n_bins","(","int",",","optional",")",":","number","of","bins","to","be","used","for","bin-based","uplift","filter","methods","null_impute","(","str",",","optional",",","default=None",")",":","impute","np.nan","present","in","the","data","taking","on","of","the","following","strategy","values","{","'mean","'",",","'median","'",",","'most_frequent","'",",","None","}",".","If","value","is","None","and","null","is","present","then","exception","will","be","raised","order","(","int",")",":","the","order","of","feature","to","be","evaluated","with","the","treatment","effect","for","F","filter","and","LR","filter",",","order","takes","3","values",":","1,2,3.","order","=","1","corresponds","to","linear","importance","of","the","feature",",","order=2","corresponds","to","quadratic","and","linear","importance","of","the","feature",",","order=","3","will","calculate","feature","importance","up","to","cubic","forms",".","disp","(","bool",")",":","Set","to","True","to","print","convergence","messages","for","Logistic","regression","convergence","in","LR","method",".","Returns",":","all_result",":","pd.DataFrame","a","data","frame","with","following","columns",":","[","'method","'",",","'feature","'",",","'rank","'",",","'score","'",",","'p_value","'",",","'misc","'","]"]
code: def get_importance(
      self,
      data,
      features,
      y_name,
      method,
      experiment_group_column="treatment_group_key",
      control_group="control",
      treatment_group="treatment",
      n_bins=5,
      null_impute=None,
      order=1,
      disp=False,
  ):
      """
      Rank features based on the chosen statistic of the interaction.
  
      Args:
          data (pd.Dataframe): DataFrame containing outcome, features, and experiment group
          features (list of string): list of feature names, that are columns in the data DataFrame
          y_name (string): name of the outcome variable
          method (string, optional, default = 'KL'): taking one of the following values {'F', 'LR', 'KL', 'ED', 'Chi'}
              The feature selection method to be used to rank the features.
              'F' for F-test
              'LR' for likelihood ratio test
              'KL', 'ED', 'Chi' for bin-based uplift filter methods, KL divergence, Euclidean distance, Chi-Square respectively
          experiment_group_column (string): the experiment column name in the DataFrame, which contains the treatment and control assignment label
          control_group (string): name for control group, value in the experiment group column
          treatment_group (string): name for treatment group, value in the experiment group column
          n_bins (int, optional): number of bins to be used for bin-based uplift filter methods
          null_impute (str, optional, default=None): impute np.nan present in the data taking on of the following strategy values {'mean', 'median', 'most_frequent', None}. If value is None and null is present then exception will be raised
          order (int): the order of feature to be evaluated with the treatment effect for F filter and LR filter, order takes 3 values: 1,2,3. order = 1 corresponds to linear importance of the feature, order=2 corresponds to quadratic and linear importance of the feature,
          order= 3 will calculate feature importance up to cubic forms.
          disp (bool): Set to True to print convergence messages for Logistic regression convergence in LR method.
  
      Returns:
          all_result : pd.DataFrame
              a data frame with following columns: ['method', 'feature', 'rank', 'score', 'p_value', 'misc']
      """
  
      if method == "F":
          data = data[
              data[experiment_group_column].isin(
                  [control_group, treatment_group]
              )
          ]
          data["treatment_indicator"] = 0
          data.loc[
              data[experiment_group_column] == treatment_group,
              "treatment_indicator",
          ] = 1
          all_result = self.filter_F(
              data=data,
              treatment_indicator="treatment_indicator",
              features=features,
              y_name=y_name,
              order=order,
          )
      elif method == "LR":
          data = data[
              data[experiment_group_column].isin(
                  [control_group, treatment_group]
              )
          ]
          data["treatment_indicator"] = 0
          data.loc[
              data[experiment_group_column] == treatment_group,
              "treatment_indicator",
          ] = 1
          all_result = self.filter_LR(
              data=data,
              disp=disp,
              treatment_indicator="treatment_indicator",
              features=features,
              y_name=y_name,
              order=order,
          )
      else:
          all_result = self.filter_D(
              data=data,
              method=method,
              features=features,
              y_name=y_name,
              n_bins=n_bins,
              control_group=control_group,
              experiment_group_column=experiment_group_column,
              null_impute=null_impute,
          )
  
      all_result["method"] = method + " filter"
      return all_result[
          ["method", "feature", "rank", "score", "p_value", "misc"]
      ]
  
imports: import numpy
  import pandas
  import statsmodels.api
  from scipy import stats
  from sklearn.impute import SimpleImputer
  import warnings
label_desc: Use image node_id 13 for calling the FilterSelect obj's underlying member method code with example usage: obj.get_importance(data, features, y_name, method, experiment_group_column, control_group, treatment_group, n_bins, null_impute, order, disp) and returns: all_result