class_docstr: Grid search reduction for fair classification or regression.
  
  Grid search is an in-processing technique that can be used for fair
  classification or fair regression. For classification it reduces fair
  classification to a sequence of cost-sensitive classification problems,
  returning the deterministic classifier with the lowest empirical error
  subject to fair classification constraints [#agarwal18]_ among the
  candidates searched. For regression it uses the same priniciple to return a
  deterministic regressor with the lowest empirical error subject to the
  constraint of bounded group loss [#agarwal19]_.
  
  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>`_
      .. [#agarwal19] `A. Agarwal, M. Dudik, and Z. Wu, "Fair Regression:
         Quantitative Definitions and Reduction-based Algorithms,"
         International Conference on Machine Learning, 2019.
         <https://arxiv.org/abs/1905.12843>`_
docstr: Obtain the predictions for the provided dataset using the model
  learned.
  
  Args:
      dataset: Dataset containing output values that need to be
          transformed.
  
  Returns:
      dataset: Transformed dataset.
code: def predict(self, dataset):
      """Obtain the predictions for the provided dataset using the model
      learned.
  
      Args:
          dataset: Dataset containing output values that need to be
              transformed.
  
      Returns:
          dataset: Transformed dataset.
      """
      X_df = pd.DataFrame(
          dataset.features, columns=dataset.feature_names
      )
  
      dataset_new = dataset.copy()
      dataset_new.labels = self.model.predict(X_df).reshape(-1, 1)
  
      if isinstance(self.model.moment_, red.ClassificationMoment):
          fav = int(dataset.favorable_label)
          try:
              # Probability of favorable label
              scores = self.model.predict_proba(X_df)[:, fav]
              dataset_new.scores = scores.reshape(-1, 1)
          except (AttributeError, NotImplementedError):
              warning(
                  "dataset.scores not updated, underlying model does not "
                  "support predict_proba"
              )
  
      return dataset_new
  
file_path: AIF360/aif360/algorithms/inprocessing/grid_search_reduction.py
imports: from logging import warning
  import pandas
  from aif360.algorithms import Transformer
  from aif360.sklearn.inprocessing import GridSearchReduction
label_desc: Use image node_id 3 for calling the GridSearchReduction obj's underlying member method code with example usage: obj.predict(dataset) and returns: dataset_new