class_docstr: Calibrated equalized odds post-processor.
  
  Calibrated equalized odds is a post-processing technique that optimizes over
  calibrated classifier score outputs to find probabilities with which to
  change output labels with an equalized odds objective [#pleiss17]_.
  
  Note:
      A :class:`~sklearn.pipeline.Pipeline` expects a single estimation step
      but this class requires an estimator's predictions as input. See
      :class:`PostProcessingMeta` for a workaround.
  
  See also:
      :class:`PostProcessingMeta`
  
  References:
      .. [#pleiss17] `G. Pleiss, M. Raghavan, F. Wu, J. Kleinberg, and
         K. Q. Weinberger, "On Fairness and Calibration," Conference on Neural
         Information Processing Systems, 2017.
         <http://papers.nips.cc/paper/7151-on-fairness-and-calibration.pdf>`_
  
  Adapted from:
  https://github.com/gpleiss/equalized_odds_and_calibration/blob/master/calib_eq_odds.py
  
  Attributes:
      prot_attr_ (str or list(str)): Protected attribute(s) used for post-
          processing.
      groups_ (array, shape (2,)): A list of group labels known to the
          classifier. Note: this algorithm require a binary division of the
          data.
      classes_ (array, shape (num_classes,)): A list of class labels known to
          the classifier. Note: this algorithm treats all non-positive
          outcomes as negative (binary classification only).
      pos_label_ (scalar): The label of the positive class.
      mix_rates_ (array, shape (2,)): The interpolation parameters -- the
          probability of randomly returning the group's base rate. The group
          for which the cost function is higher is set to 0.
class_docstr_tok: ["Calibrated","equalized","odds","post-processor",".","Calibrated","equalized","odds","is","a","post-processing","technique","that","optimizes","over","calibrated","classifier","score","outputs","to","find","probabilities","with","which","to","change","output","labels","with","an","equalized","odds","objective","[","#","pleiss17","]","_",".","Note",":","A",":","class",":","`","~sklearn.pipeline.Pipeline","`","expects","a","single","estimation","step","but","this","class","requires","an","estimator","'s","predictions","as","input",".","See",":","class",":","`","PostProcessingMeta","`","for","a","workaround",".","See","also",":",":","class",":","`","PostProcessingMeta","`","References",":","..","[","#","pleiss17","]","`","G.","Pleiss",",","M.","Raghavan",",","F.","Wu",",","J.","Kleinberg",",","and","K.","Q.","Weinberger",",","``","On","Fairness","and","Calibration",",","''","Conference","on","Neural","Information","Processing","Systems",",","2017",".","<","http",":","\/\/papers.nips.cc\/paper\/7151-on-fairness-and-calibration.pdf",">","`","_","Adapted","from",":","https",":","\/\/github.com\/gpleiss\/equalized_odds_and_calibration\/blob\/master\/calib_eq_odds.py","Attributes",":","prot_attr_","(","str","or","list","(","str",")",")",":","Protected","attribute","(","s",")","used","for","post-","processing",".","groups_","(","array",",","shape","(","2",",",")",")",":","A","list","of","group","labels","known","to","the","classifier",".","Note",":","this","algorithm","require","a","binary","division","of","the","data",".","classes_","(","array",",","shape","(","num_classes",",",")",")",":","A","list","of","class","labels","known","to","the","classifier",".","Note",":","this","algorithm","treats","all","non-positive","outcomes","as","negative","(","binary","classification","only",")",".","pos_label_","(","scalar",")",":","The","label","of","the","positive","class",".","mix_rates_","(","array",",","shape","(","2",",",")",")",":","The","interpolation","parameters","--","the","probability","of","randomly","returning","the","group","'s","base","rate",".","The","group","for","which","the","cost","function","is","higher","is","set","to","0","."]
docstr: Evaluates the cost function specified by ``self.cost_constraint``.
docstr_tok: ["Evaluates","the","cost","function","specified","by","``","self.cost_constraint","``","."]
code: def _weighted_cost(
      self, y_true, probas_pred, pos_label=1, sample_weight=None
  ):
      """Evaluates the cost function specified by ``self.cost_constraint``."""
      if self.cost_constraint == "fpr":
          return generalized_fpr(
              y_true,
              probas_pred,
              pos_label=pos_label,
              sample_weight=sample_weight,
          )
      elif self.cost_constraint == "fnr":
          return generalized_fnr(
              y_true,
              probas_pred,
              pos_label=pos_label,
              sample_weight=sample_weight,
          )
      elif self.cost_constraint == "weighted":
          fpr = generalized_fpr(
              y_true,
              probas_pred,
              pos_label=pos_label,
              sample_weight=sample_weight,
          )
          fnr = generalized_fnr(
              y_true,
              probas_pred,
              pos_label=pos_label,
              sample_weight=sample_weight,
          )
          br = base_rate(
              y_true,
              probas_pred,
              pos_label=pos_label,
              sample_weight=sample_weight,
          )
          return fpr * (1 - br) + fnr * br
      else:
          raise ValueError(
              "`cost_constraint` must be one of: 'fpr', 'fnr', "
              "or 'weighted'"
          )
  
file_path: AIF360/aif360/sklearn/postprocessing/calibrated_equalized_odds.py
imports: import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_is_fitted
  from aif360.sklearn.metrics import difference, base_rate
  from aif360.sklearn.metrics import generalized_fnr, generalized_fpr
  from aif360.sklearn.utils import check_inputs, check_groups
label_desc: Use image node_id 3 for calling the CalibratedEqualizedOdds obj's underlying member method code with example usage: obj._weighted_cost(y_true, probas_pred, pos_label, sample_weight) and returns: generalized_fpr, generalized_fnr, unknown