class_docstr: This is the Auditor class. It is used in the training algorithm to repeatedly find subgroups that break the
  fairness disparity constraint. You can also use it independently as a stand alone auditor.
class_docstr_tok: ["This","is","the","Auditor","class",".","It","is","used","in","the","training","algorithm","to","repeatedly","find","subgroups","that","break","the","fairness","disparity","constraint",".","You","can","also","use","it","independently","as","a","stand","alone","auditor","."]
docstr: Given decisions on sensitive attributes, labels, and FP rate audit wrt
      to gamma unfairness. Return the group found, the gamma unfairness, fp disparity, and sign(fp disparity).
  
  Args:
      :param predictions: soft predictions of the classifier
      :param metric_baseline: see function get_baseline
  
  Returns:
      :return func: object of type RegOracle defining the group
      :return g_size_0: the size of the group divided by n
      :return fp_disp: |group_rate-baseline|
      :return fp_disp_w: fp_disp*group_size_0
      :return sgn(fp_disp): sgn(group_rate-baseline)
      :return fp_group_rate_neg:
docstr_tok: ["Given","decisions","on","sensitive","attributes",",","labels",",","and","FP","rate","audit","wrt","to","gamma","unfairness",".","Return","the","group","found",",","the","gamma","unfairness",",","fp","disparity",",","and","sign","(","fp","disparity",")",".","Args",":",":","param","predictions",":","soft","predictions","of","the","classifier",":","param","metric_baseline",":","see","function","get_baseline","Returns",":",":","return","func",":","object","of","type","RegOracle","defining","the","group",":","return","g_size_0",":","the","size","of","the","group","divided","by","n",":","return","fp_disp",":","|group_rate-baseline|",":","return","fp_disp_w",":","fp_disp","*","group_size_0",":","return","sgn","(","fp_disp",")",":","sgn","(","group_rate-baseline",")",":","return","fp_group_rate_neg",":"]
code: def get_group(self, predictions, metric_baseline):
      """Given decisions on sensitive attributes, labels, and FP rate audit wrt
          to gamma unfairness. Return the group found, the gamma unfairness, fp disparity, and sign(fp disparity).
  
      Args:
          :param predictions: soft predictions of the classifier
          :param metric_baseline: see function get_baseline
  
      Returns:
          :return func: object of type RegOracle defining the group
          :return g_size_0: the size of the group divided by n
          :return fp_disp: |group_rate-baseline|
          :return fp_disp_w: fp_disp*group_size_0
          :return sgn(fp_disp): sgn(group_rate-baseline)
          :return fp_group_rate_neg:
      """
  
      X_subset, predictions_subset = self.get_subset(predictions)
  
      m = len(predictions_subset)
      n = float(len(self.y))
  
      cost_0 = [0.0] * m
      cost_1 = -1.0 / n * (metric_baseline - predictions_subset)
  
      reg0 = linear_model.LinearRegression()
      reg0.fit(X_subset, cost_0)
      reg1 = linear_model.LinearRegression()
      reg1.fit(X_subset, cost_1)
      func = RegOracle(reg0, reg1)
      group_members_0 = func.predict(X_subset)
  
      # get the false positive rate in group
      if sum(group_members_0) == 0:
          fp_group_rate = 0
      else:
          fp_group_rate = np.mean(
              [
                  r
                  for t, r in enumerate(predictions_subset)
                  if group_members_0[t] == 1
              ]
          )
      g_size_0 = np.sum(group_members_0) * 1.0 / n
      fp_disp = np.abs(fp_group_rate - metric_baseline)
      fp_disp_w = fp_disp * g_size_0
  
      cost_0_neg = [0.0] * m
      cost_1_neg = -1.0 / n * (predictions_subset - metric_baseline)
  
      reg0_neg = linear_model.LinearRegression()
      reg0_neg.fit(X_subset, cost_0_neg)
      reg1_neg = linear_model.LinearRegression()
      reg1_neg.fit(X_subset, cost_1_neg)
      func_neg = RegOracle(reg0_neg, reg1_neg)
      group_members_0_neg = func_neg.predict(X_subset)
  
      if sum(group_members_0_neg) == 0:
          fp_group_rate_neg = 0
      else:
          fp_group_rate_neg = np.mean(
              [
                  r
                  for t, r in enumerate(predictions_subset)
                  if group_members_0[t] == 0
              ]
          )
      g_size_0_neg = np.sum(group_members_0_neg) * 1.0 / n
      fp_disp_neg = np.abs(fp_group_rate_neg - metric_baseline)
      fp_disp_w_neg = fp_disp_neg * g_size_0_neg
  
      # return group
      if fp_disp_w_neg > fp_disp_w:
          return Group(
              func_neg,
              g_size_0_neg,
              fp_disp_w_neg,
              fp_disp_neg,
              -1,
              fp_group_rate,
          )
      else:
          return Group(
              func, g_size_0, fp_disp_w, fp_disp, 1, fp_group_rate_neg
          )
  
file_path: AIF360/aif360/algorithms/inprocessing/gerryfair/auditor.py
imports: import numpy
  import pandas
  from sklearn import linear_model
  from aif360.algorithms.inprocessing.gerryfair.reg_oracle_class import RegOracle
  from aif360.algorithms.inprocessing.gerryfair import clean
label_desc: Use image node_id 6 for calling the Auditor obj's underlying member method code with example usage: obj.get_group(predictions, metric_baseline) and returns: Group, Group