class_docstr: Exponentiated gradient reduction for fair classification.
  
  Exponentiated gradient reduction is an in-processing technique that reduces
  fair classification to a sequence of cost-sensitive classification problems,
  returning a randomized classifier with the lowest empirical error subject to
  fair classification constraints [#agarwal18]_.
  
  References:
      .. [#agarwal18] `A. Agarwal, A. Beygelzimer, M. Dudik, J. Langford, and
         H. Wallach, "A Reductions Approach to Fair Classification,"
         International Conference on Machine Learning, 2018.
         <https://arxiv.org/abs/1803.02453>`_
docstr: Learns randomized model with less bias
  
  Args:
      X (pandas.DataFrame): Training samples.
      y (array-like): Training labels.
  
  Returns:
      self
code: def fit(self, X, y):
      """Learns randomized model with less bias
  
      Args:
          X (pandas.DataFrame): Training samples.
          y (array-like): Training labels.
  
      Returns:
          self
      """
      self.estimator_ = clone(self.estimator)
  
      moments = {
          "DemographicParity": red.DemographicParity,
          "EqualizedOdds": red.EqualizedOdds,
          "TruePositiveRateParity": red.TruePositiveRateParity,
          "FalsePositiveRateParity": red.FalsePositiveRateParity,
          "ErrorRateParity": red.ErrorRateParity,
      }
      if isinstance(self.constraints, str):
          if self.constraints not in moments:
              raise ValueError(
                  f"Constraint not recognized: {self.constraints}"
              )
          self.moment_ = moments[self.constraints]()
      elif isinstance(self.constraints, red.Moment):
          self.moment_ = self.constraints
      else:
          raise ValueError(
              "constraints must be a string or Moment object."
          )
  
      self.model_ = red.ExponentiatedGradient(
          self.estimator_,
          self.moment_,
          eps=self.eps,
          max_iter=self.max_iter,
          nu=self.nu,
          eta0=self.eta0,
      )
  
      A = X[self.prot_attr]
  
      if self.drop_prot_attr:
          X = X.drop(self.prot_attr, axis=1)
  
      le = LabelEncoder()
      y = le.fit_transform(y)
      self.classes_ = le.classes_
  
      self.model_.fit(X, y, sensitive_features=A)
  
      return self
  
file_path: AIF360/aif360/sklearn/inprocessing/exponentiated_gradient_reduction.py
imports: from sklearn.base import BaseEstimator, ClassifierMixin, clone
  from sklearn.preprocessing import LabelEncoder
label_desc: Use image node_id 2 for calling the ExponentiatedGradientReduction obj's underlying member method code with example usage: obj.fit(X, y) and returns: self