class_docstr: A class for feature importance methods.
class_docstr_tok: ["A","class","for","feature","importance","methods","."]
docstr: Conduct LR (Likelihood Ratio) test of the interaction between treatment and one feature.
  
  Args:
      data (pd.Dataframe): DataFrame containing outcome, features, and experiment group
      treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0)
      feature_name (string): feature name, as one column in the data DataFrame
      y_name (string): name of the outcome variable
      order (int): the order of feature to be evaluated with the treatment effect, 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.
  
  Returns:
      LR_test_result : pd.DataFrame
          a data frame containing the feature importance statistics
docstr_tok: ["Conduct","LR","(","Likelihood","Ratio",")","test","of","the","interaction","between","treatment","and","one","feature",".","Args",":","data","(","pd.Dataframe",")",":","DataFrame","containing","outcome",",","features",",","and","experiment","group","treatment_indicator","(","string",")",":","the","column","name","for","binary","indicator","of","treatment","(","value","1",")","or","control","(","value","0",")","feature_name","(","string",")",":","feature","name",",","as","one","column","in","the","data","DataFrame","y_name","(","string",")",":","name","of","the","outcome","variable","order","(","int",")",":","the","order","of","feature","to","be","evaluated","with","the","treatment","effect",",","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",".","Returns",":","LR_test_result",":","pd.DataFrame","a","data","frame","containing","the","feature","importance","statistics"]
code: def _filter_LR_one_feature(
      data,
      treatment_indicator,
      feature_name,
      y_name,
      order=1,
      disp=True,
  ):
      """
      Conduct LR (Likelihood Ratio) test of the interaction between treatment and one feature.
  
      Args:
          data (pd.Dataframe): DataFrame containing outcome, features, and experiment group
          treatment_indicator (string): the column name for binary indicator of treatment (value 1) or control (value 0)
          feature_name (string): feature name, as one column in the data DataFrame
          y_name (string): name of the outcome variable
          order (int): the order of feature to be evaluated with the treatment effect, 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.
  
      Returns:
          LR_test_result : pd.DataFrame
              a data frame containing the feature importance statistics
      """
      Y = data[y_name]
  
      # Restricted model
      x_name_r = ["const", treatment_indicator, feature_name]
      x_name_f = x_name_r.copy()
      X = data[[treatment_indicator, feature_name]]
      X = sm.add_constant(X)
  
      X["{}-{}".format(treatment_indicator, feature_name)] = X[
          [treatment_indicator, feature_name]
      ].product(axis=1)
      x_name_f.append("{}-{}".format(treatment_indicator, feature_name))
  
      if order == 2:
          x_tmp_name = "{}_o{}".format(feature_name, order)
          X[x_tmp_name] = X[[feature_name]] ** order
          X["{}-{}".format(treatment_indicator, x_tmp_name)] = X[
              [treatment_indicator, x_tmp_name]
          ].product(axis=1)
          x_name_r.append(x_tmp_name)
          x_name_f += [
              x_tmp_name,
              "{}-{}".format(treatment_indicator, x_tmp_name),
          ]
      elif order == 3:
          x_tmp_name = "{}_o{}".format(feature_name, 2)
          X[x_tmp_name] = X[[feature_name]] ** 2
          X["{}-{}".format(treatment_indicator, x_tmp_name)] = X[
              [treatment_indicator, x_tmp_name]
          ].product(axis=1)
          x_name_r.append(x_tmp_name)
          x_name_f += [
              x_tmp_name,
              "{}-{}".format(treatment_indicator, x_tmp_name),
          ]
          x_tmp_name = "{}_o{}".format(feature_name, order)
          X[x_tmp_name] = X[[feature_name]] ** order
          X["{}-{}".format(treatment_indicator, x_tmp_name)] = X[
              [treatment_indicator, x_tmp_name]
          ].product(axis=1)
          x_name_r.append(x_tmp_name)
          x_name_f += [
              x_tmp_name,
              "{}-{}".format(treatment_indicator, x_tmp_name),
          ]
  
      # Full model (with interaction)
      model_r = sm.Logit(Y, X[x_name_r])
      result_r = model_r.fit(disp=disp)
  
      model_f = sm.Logit(Y, X[x_name_f])
      result_f = model_f.fit(disp=disp)
  
      LR_stat = -2 * (result_r.llf - result_f.llf)
      LR_df = len(result_f.params) - len(result_r.params)
      LR_pvalue = 1 - stats.chi2.cdf(LR_stat, df=LR_df)
  
      LR_test_result = pd.DataFrame(
          {
              "feature": feature_name,  # for the interaction, not the main effect
              "method": "LR{} Filter".format(order),
              "score": LR_stat,
              "p_value": LR_pvalue,
              "misc": "df: {}, order: {}".format(LR_df, order),
          },
          index=[0],
      ).reset_index(drop=True)
  
      return LR_test_result
  
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 4 for calling the FilterSelect obj's underlying member method code with example usage: obj._filter_LR_one_feature(data, treatment_indicator, feature_name, y_name, order, disp) and returns: LR_test_result