class_docstr: Metric that computes bounded AUC for predictions in [0, 1].
  
  This metrics calculates the subgroup auc, the background positive subgroup
  negative auc and background negative subgroup positive auc. For more
  explanation about the concepts of these auc metrics, please refer to paper
  [Measuring and Mitigating Unintended Bias in Text
  Classification](https://ai.google/research/pubs/pub46743)
class_docstr_tok: ["Metric","that","computes","bounded","AUC","for","predictions","in","[","0",",","1","]",".","This","metrics","calculates","the","subgroup","auc",",","the","background","positive","subgroup","negative","auc","and","background","negative","subgroup","positive","auc",".","For","more","explanation","about","the","concepts","of","these","auc","metrics",",","please","refer","to","paper","[","Measuring","and","Mitigating","Unintended","Bias","in","Text","Classification","]","(","https",":","\/\/ai.google\/research\/pubs\/pub46743",")"]
docstr: Create a metric that computes fairness auc.
  
  Predictions should be one of:
    (a) a single float in [0, 1]
    (b) a dict containing the LOGISTIC key
    (c) a dict containing the PREDICTIONS key, where the prediction is
        in [0, 1]
  
  Label should be a single float that is either exactly 0 or exactly 1
  (soft labels, i.e. labels between 0 and 1 are *not* supported).
  
  Args:
    subgroup_key: The key inside the feature column to indicate where this
      example belongs to the subgroup or not. The expected mapping tensor of
      this key should contain an integer/float value that's either 1 or 0.
    example_weight_key: The key of the example weight column in the features
      dict. If None, all predictions are given a weight of 1.0.
    num_buckets: The number of buckets used for the curve. (num_buckets + 1)
      is used as the num_thresholds in tf.metrics.auc().
    target_prediction_keys: If provided, the prediction keys to look for in
      order.
    labels_key: If provided, a custom label key.
    metric_tag: If provided, a custom metric tag. Only necessary to
      disambiguate instances of the same metric on different predictions.
    tensor_index: Optional index to specify class predictions to calculate
      metrics on in the case of multi-class models.
docstr_tok: ["Create","a","metric","that","computes","fairness","auc",".","Predictions","should","be","one","of",":","(","a",")","a","single","float","in","[","0",",","1","]","(","b",")","a","dict","containing","the","LOGISTIC","key","(","c",")","a","dict","containing","the","PREDICTIONS","key",",","where","the","prediction","is","in","[","0",",","1","]","Label","should","be","a","single","float","that","is","either","exactly","0","or","exactly","1","(","soft","labels",",","i.e",".","labels","between","0","and","1","are","*","not","*","supported",")",".","Args",":","subgroup_key",":","The","key","inside","the","feature","column","to","indicate","where","this","example","belongs","to","the","subgroup","or","not",".","The","expected","mapping","tensor","of","this","key","should","contain","an","integer\/float","value","that","'s","either","1","or","0.","example_weight_key",":","The","key","of","the","example","weight","column","in","the","features","dict",".","If","None",",","all","predictions","are","given","a","weight","of","1.0.","num_buckets",":","The","number","of","buckets","used","for","the","curve",".","(","num_buckets","+","1",")","is","used","as","the","num_thresholds","in","tf.metrics.auc","(",")",".","target_prediction_keys",":","If","provided",",","the","prediction","keys","to","look","for","in","order",".","labels_key",":","If","provided",",","a","custom","label","key",".","metric_tag",":","If","provided",",","a","custom","metric","tag",".","Only","necessary","to","disambiguate","instances","of","the","same","metric","on","different","predictions",".","tensor_index",":","Optional","index","to","specify","class","predictions","to","calculate","metrics","on","in","the","case","of","multi-class","models","."]
code: def __init__(
      self,
      subgroup_key: str,
      example_weight_key: Optional[str] = None,
      num_buckets: int = post_export_metrics._DEFAULT_NUM_BUCKETS,
      target_prediction_keys: Optional[List[str]] = None,
      labels_key: Optional[str] = None,
      metric_tag: Optional[str] = None,
      tensor_index: Optional[int] = None,
  ) -> None:
      """Create a metric that computes fairness auc.
  
      Predictions should be one of:
        (a) a single float in [0, 1]
        (b) a dict containing the LOGISTIC key
        (c) a dict containing the PREDICTIONS key, where the prediction is
            in [0, 1]
  
      Label should be a single float that is either exactly 0 or exactly 1
      (soft labels, i.e. labels between 0 and 1 are *not* supported).
  
      Args:
        subgroup_key: The key inside the feature column to indicate where this
          example belongs to the subgroup or not. The expected mapping tensor of
          this key should contain an integer/float value that's either 1 or 0.
        example_weight_key: The key of the example weight column in the features
          dict. If None, all predictions are given a weight of 1.0.
        num_buckets: The number of buckets used for the curve. (num_buckets + 1)
          is used as the num_thresholds in tf.metrics.auc().
        target_prediction_keys: If provided, the prediction keys to look for in
          order.
        labels_key: If provided, a custom label key.
        metric_tag: If provided, a custom metric tag. Only necessary to
          disambiguate instances of the same metric on different predictions.
        tensor_index: Optional index to specify class predictions to calculate
          metrics on in the case of multi-class models.
      """
  
      self._subgroup_key = subgroup_key
      self._example_weight_key = example_weight_key
      self._curve = "ROC"
      self._num_buckets = num_buckets
      self._metric_name = metric_keys.FAIRNESS_AUC
      self._subgroup_auc_metric = self._metric_key(
          self._metric_name + "/subgroup_auc/" + self._subgroup_key
      )
      self._bpsn_auc_metric = self._metric_key(
          self._metric_name + "/bpsn_auc/" + self._subgroup_key
      )
      self._bnsp_auc_metric = self._metric_key(
          self._metric_name + "/bnsp_auc/" + self._subgroup_key
      )
  
      super().__init__(
          target_prediction_keys=target_prediction_keys,
          labels_key=labels_key,
          metric_tag=metric_tag,
          tensor_index=tensor_index,
      )
  
file_path: model-analysis/tensorflow_model_analysis/addons/fairness/post_export_metrics/fairness_indicators.py
imports: from typing import Any, Dict, List, Optional, Tuple
  import tensorflow
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.post_export_metrics import post_export_metrics
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
label_desc: Use image node_id 1 to create a new _FairnessAuc object from inherited base classes: post_export_metrics with example: obj = _FairnessAuc(subgroup_key, example_weight_key, num_buckets, target_prediction_keys, labels_key, metric_tag, tensor_index)