docstr: Calculate intersectional fairness metrics.
  
  :param frame: Frame used to calculate the metrics.
  :param protected_columns: List of categorical columns that contain sensitive information
                            such as race, gender, age etc.
  :param reference: List of values corresponding to a reference for each protected columns.
                    If set to None, it will use the biggest group as the reference.
  :param favorable_class: Positive/favorable outcome class of the response.
  
  :return: Dictionary of frames. One frame is the overview, other frames contain dependence
           of performance on threshold for each protected group.
  
  :examples:
  >>> from h2o.estimators import H2OGradientBoostingEstimator
  >>> data = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/admissibleml_test/taiwan_credit_card_uci.csv")
  >>> x = ['LIMIT_BAL', 'AGE', 'PAY_0', 'PAY_2', 'PAY_3', 'PAY_4', 'PAY_5', 'PAY_6', 'BILL_AMT1', 'BILL_AMT2', 'BILL_AMT3',
  >>>      'BILL_AMT4', 'BILL_AMT5', 'BILL_AMT6', 'PAY_AMT1', 'PAY_AMT2', 'PAY_AMT3', 'PAY_AMT4', 'PAY_AMT5', 'PAY_AMT6']
  >>> y = "default payment next month"
  >>> protected_columns = ['SEX', 'EDUCATION']
  >>>
  >>> for c in [y] + protected_columns:
  >>>     data[c] = data[c].asfactor()
  >>>
  >>> train, test = data.split_frame([0.8])
  >>>
  >>> reference = ["1", "2"]  # university educated single man
  >>> favorable_class = "0"  # no default next month
  >>>
  >>> gbm = H2OGradientBoostingEstimator()
  >>> gbm.train(x, y, training_frame=train)
  >>>
  >>> fairness_metrics = gbm.fairness_metrics(test, protected_columns, reference, favorable_class)
  >>> display(fairness_metrics["overview"])
docstr_tok: ["Calculate","intersectional","fairness","metrics",".",":","param","frame",":","Frame","used","to","calculate","the","metrics",".",":","param","protected_columns",":","List","of","categorical","columns","that","contain","sensitive","information","such","as","race",",","gender",",","age","etc",".",":","param","reference",":","List","of","values","corresponding","to","a","reference","for","each","protected","columns",".","If","set","to","None",",","it","will","use","the","biggest","group","as","the","reference",".",":","param","favorable_class",":","Positive\/favorable","outcome","class","of","the","response",".",":","return",":","Dictionary","of","frames",".","One","frame","is","the","overview",",","other","frames","contain","dependence","of","performance","on","threshold","for","each","protected","group",".",":","examples",":",">",">",">","from","h2o.estimators","import","H2OGradientBoostingEstimator",">",">",">","data","=","h2o.import_file","(","``","https",":","\/\/s3.amazonaws.com\/h2o-public-test-data\/smalldata\/admissibleml_test\/taiwan_credit_card_uci.csv","''",")",">",">",">","x","=","[","'LIMIT_BAL","'",",","'AGE","'",",","'PAY_0","'",",","'PAY_2","'",",","'PAY_3","'",",","'PAY_4","'",",","'PAY_5","'",",","'PAY_6","'",",","'BILL_AMT1","'",",","'BILL_AMT2","'",",","'BILL_AMT3","'",",",">",">",">","'BILL_AMT4","'",",","'BILL_AMT5","'",",","'BILL_AMT6","'",",","'PAY_AMT1","'",",","'PAY_AMT2","'",",","'PAY_AMT3","'",",","'PAY_AMT4","'",",","'PAY_AMT5","'",",","'PAY_AMT6","'","]",">",">",">","y","=","``","default","payment","next","month","''",">",">",">","protected_columns","=","[","'SEX","'",",","'EDUCATION","'","]",">",">",">",">",">",">","for","c","in","[","y","]","+","protected_columns",":",">",">",">","data","[","c","]","=","data","[","c","]",".asfactor","(",")",">",">",">",">",">",">","train",",","test","=","data.split_frame","(","[","0.8","]",")",">",">",">",">",">",">","reference","=","[","``","1","''",",","``","2","''","]","#","university","educated","single","man",">",">",">","favorable_class","=","``","0","''","#","no","default","next","month",">",">",">",">",">",">","gbm","=","H2OGradientBoostingEstimator","(",")",">",">",">","gbm.train","(","x",",","y",",","training_frame=train",")",">",">",">",">",">",">","fairness_metrics","=","gbm.fairness_metrics","(","test",",","protected_columns",",","reference",",","favorable_class",")",">",">",">","display","(","fairness_metrics","[","``","overview","''","]",")"]
code: def fairness_metrics(
      self, frame, protected_columns, reference, favorable_class
  ):
      """
      Calculate intersectional fairness metrics.
  
      :param frame: Frame used to calculate the metrics.
      :param protected_columns: List of categorical columns that contain sensitive information
                                such as race, gender, age etc.
      :param reference: List of values corresponding to a reference for each protected columns.
                        If set to None, it will use the biggest group as the reference.
      :param favorable_class: Positive/favorable outcome class of the response.
  
      :return: Dictionary of frames. One frame is the overview, other frames contain dependence
               of performance on threshold for each protected group.
  
      :examples:
      >>> from h2o.estimators import H2OGradientBoostingEstimator
      >>> data = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/admissibleml_test/taiwan_credit_card_uci.csv")
      >>> x = ['LIMIT_BAL', 'AGE', 'PAY_0', 'PAY_2', 'PAY_3', 'PAY_4', 'PAY_5', 'PAY_6', 'BILL_AMT1', 'BILL_AMT2', 'BILL_AMT3',
      >>>      'BILL_AMT4', 'BILL_AMT5', 'BILL_AMT6', 'PAY_AMT1', 'PAY_AMT2', 'PAY_AMT3', 'PAY_AMT4', 'PAY_AMT5', 'PAY_AMT6']
      >>> y = "default payment next month"
      >>> protected_columns = ['SEX', 'EDUCATION']
      >>>
      >>> for c in [y] + protected_columns:
      >>>     data[c] = data[c].asfactor()
      >>>
      >>> train, test = data.split_frame([0.8])
      >>>
      >>> reference = ["1", "2"]  # university educated single man
      >>> favorable_class = "0"  # no default next month
      >>>
      >>> gbm = H2OGradientBoostingEstimator()
      >>> gbm.train(x, y, training_frame=train)
      >>>
      >>> fairness_metrics = gbm.fairness_metrics(test, protected_columns, reference, favorable_class)
      >>> display(fairness_metrics["overview"])
      """
      import h2o
      from h2o.utils.typechecks import assert_is_type
      from h2o.expr import ExprNode
  
      assert_is_type(frame, h2o.H2OFrame)
      assert_is_type(protected_columns, [str])
      assert_is_type(reference, [str], None)
      assert_is_type(favorable_class, str)
  
      expr = ExprNode(
          "fairnessMetrics",
          self,
          frame,
          protected_columns,
          reference,
          favorable_class,
      )
      res = expr._eager_map_frame()
  
      def _get_tracked_frame(frame_id):
          expr = ExprNode()
          expr._cache._id = frame_id
          return h2o.H2OFrame._expr(expr)
  
      return {
          n: _get_tracked_frame(f["key"]["name"])
          for n, f in zip(res.map_keys["string"], res.frames)
      }
  
file_path: h2o-3/h2o-py/h2o/model/extensions/fairness.py
imports: from collections import defaultdict
  from itertools import product
  from h2o.utils.threading import local_context
label_desc: Use image node_id 1 for calling the Fairness obj's underlying member method code with example usage: obj.fairness_metrics(frame, protected_columns, reference, favorable_class) and returns: unknown, h2o