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: The returned estimates for all classes are ordered by the label of
  classes.
  
  Args:
      X (pandas.DataFrame): Probability estimates of the targets as
          returned by a ``predict_proba()`` call or equivalent. Note: must
          include protected attributes in the index.
  
  Returns:
      numpy.ndarray: Returns the probability of the sample for each class
      in the model, where classes are ordered as they are in
      ``self.classes_``.
docstr_tok: ["The","returned","estimates","for","all","classes","are","ordered","by","the","label","of","classes",".","Args",":","X","(","pandas.DataFrame",")",":","Probability","estimates","of","the","targets","as","returned","by","a","``","predict_proba","(",")","``","call","or","equivalent",".","Note",":","must","include","protected","attributes","in","the","index",".","Returns",":","numpy.ndarray",":","Returns","the","probability","of","the","sample","for","each","class","in","the","model",",","where","classes","are","ordered","as","they","are","in","``","self.classes_","``","."]
code: def predict_proba(self, X):
      """The returned estimates for all classes are ordered by the label of
      classes.
  
      Args:
          X (pandas.DataFrame): Probability estimates of the targets as
              returned by a ``predict_proba()`` call or equivalent. Note: must
              include protected attributes in the index.
  
      Returns:
          numpy.ndarray: Returns the probability of the sample for each class
          in the model, where classes are ordered as they are in
          ``self.classes_``.
      """
      check_is_fitted(self, "mix_rates_")
      rng = check_random_state(self.random_state)
  
      groups, _ = check_groups(X, self.prot_attr_)
      if not set(np.unique(groups)) <= set(self.groups_):
          raise ValueError(
              "The protected groups from X:\n{}\ndo not "
              "match those from the training set:\n{}".format(
                  np.unique(groups), self.groups_
              )
          )
  
      pos_idx = np.nonzero(self.classes_ == self.pos_label_)[0][0]
      X = X.iloc[:, pos_idx]
  
      yt = np.empty_like(X)
      for grp_idx in range(2):
          i = groups == self.groups_[grp_idx]
          to_replace = rng.rand(sum(i)) < self.mix_rates_[grp_idx]
          new_preds = X[i].copy()
          new_preds[to_replace] = self.base_rates_[grp_idx]
          yt[i] = new_preds
  
      return np.c_[1 - yt, yt] if pos_idx == 1 else np.c_[yt, 1 - yt]
  
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 5 for calling the CalibratedEqualizedOdds obj's underlying member method code with example usage: obj.predict_proba(X) and returns: unknown