class_docstr: A class for feature importance methods.
class_docstr_tok: ["A","class","for","feature","importance","methods","."]
docstr: To count the conversions and get the probabilities by treatment groups. This function comes from the uplift tree algorithm, that is used for tree node split evaluation.
  
  Parameters
  ----------
  data : DataFrame
      The DataFrame that contains all the data (in the current "node").
  experiment_group_column : str
      Treatment indicator column name.
  y_name : str
      Label indicator column name.
  smooth : bool
      Smooth label count by adding 1 in case certain labels do not occur
      naturally with a treatment. Prevents zero divisions.
  
  Returns
  -------
  results : dict
      Counts of conversions by treatment groups, of the form:
      {'control': {0: 10, 1: 8}, 'treatment1': {0: 5, 1: 15}}
  nodeSummary: dict
      Probability of conversion and group size by treatment groups, of
      the form:
      {'control': [0.490, 500], 'treatment1': [0.584, 500]}
docstr_tok: ["To","count","the","conversions","and","get","the","probabilities","by","treatment","groups",".","This","function","comes","from","the","uplift","tree","algorithm",",","that","is","used","for","tree","node","split","evaluation",".","Parameters","--","--","--","--","--","data",":","DataFrame","The","DataFrame","that","contains","all","the","data","(","in","the","current","``","node","''",")",".","experiment_group_column",":","str","Treatment","indicator","column","name",".","y_name",":","str","Label","indicator","column","name",".","smooth",":","bool","Smooth","label","count","by","adding","1","in","case","certain","labels","do","not","occur","naturally","with","a","treatment",".","Prevents","zero","divisions",".","Returns","--","--","--","-","results",":","dict","Counts","of","conversions","by","treatment","groups",",","of","the","form",":","{","'control","'",":","{","0",":","10",",","1",":","8","}",",","'treatment1","'",":","{","0",":","5",",","1",":","15","}","}","nodeSummary",":","dict","Probability","of","conversion","and","group","size","by","treatment","groups",",","of","the","form",":","{","'control","'",":","[","0.490",",","500","]",",","'treatment1","'",":","[","0.584",",","500","]","}"]
code: def _GetNodeSummary(
      data,
      experiment_group_column="treatment_group_key",
      y_name="conversion",
      smooth=True,
  ):
      """
      To count the conversions and get the probabilities by treatment groups. This function comes from the uplift tree algorithm, that is used for tree node split evaluation.
  
      Parameters
      ----------
      data : DataFrame
          The DataFrame that contains all the data (in the current "node").
      experiment_group_column : str
          Treatment indicator column name.
      y_name : str
          Label indicator column name.
      smooth : bool
          Smooth label count by adding 1 in case certain labels do not occur
          naturally with a treatment. Prevents zero divisions.
  
      Returns
      -------
      results : dict
          Counts of conversions by treatment groups, of the form:
          {'control': {0: 10, 1: 8}, 'treatment1': {0: 5, 1: 15}}
      nodeSummary: dict
          Probability of conversion and group size by treatment groups, of
          the form:
          {'control': [0.490, 500], 'treatment1': [0.584, 500]}
      """
  
      # Note: results and nodeSummary are both dict with treatment_group_key
      # as the key.  So we can compute the treatment effect and/or
      # divergence easily.
  
      # Counts of conversions by treatment group
      results_series = data.groupby(
          [experiment_group_column, y_name]
      ).size()
  
      treatment_group_keys = results_series.index.levels[0].tolist()
      y_name_keys = results_series.index.levels[1].tolist()
  
      results = {}
      for ti in treatment_group_keys:
          results.update({ti: {}})
          for ci in y_name_keys:
              if smooth:
                  results[ti].update(
                      {
                          ci: results_series[ti, ci]
                          if results_series.index.isin([(ti, ci)]).any()
                          else 1
                      }
                  )
              else:
                  results[ti].update({ci: results_series[ti, ci]})
  
      # Probability of conversion and group size by treatment group
      nodeSummary = {}
      for treatment_group_key in results:
          n_1 = results[treatment_group_key].get(1, 0)
          n_total = results[treatment_group_key].get(1, 0) + results[
              treatment_group_key
          ].get(0, 0)
          y_mean = 1.0 * n_1 / n_total
          nodeSummary[treatment_group_key] = [y_mean, n_total]
  
      return results, nodeSummary
  
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 6 for calling the FilterSelect obj's underlying member method code with example usage: obj._GetNodeSummary(data, experiment_group_column, y_name, smooth) and returns: results,  nodeSummary