class_docstr: Fair Data Adaptation.
  
  Fairadapt is a pre-processing technique that can be used for both fair
  classification and fair regression [#plecko20]_. The method is a causal
  inference approach to bias removal and it relies on the causal graph for
  the dataset. The original implementation is in R [#plecko21]_.
  
  References:
      .. [#plecko20] `D. Plečko and N. Meinshausen,
         "Fair Data Adaptation with Quantile Preservation,"
         Journal of Machine Learning Research, 2020.
         <https://www.jmlr.org/papers/volume21/19-966/19-966.pdf>`_
      .. [#plecko21] `D. Plečko and N. Bennett and N. Meinshausen,
         "FairAdapt: Causal Reasoning for Fair Data Pre-processing,"
         arXiv, 2021. <https://arxiv.org/abs/2110.10200>`_
  
  Attributes:
      prot_attr_ (str or list(str)): Protected attribute(s) used for fair data
          adaptation.
      groups_ (array, shape (n_groups,)): A list of group labels known to the
          transformer.
docstr: Remove bias from the given dataset by fair adaptation.
  
  Args:
      X_train (pandas.DataFrame): Training data frame (including the
          protected attribute).
      y_train (pandas.Series): Training labels.
      X_test (pandas.DataFrame): Test data frame (including the protected
          attribute).
  
  Returns:
      tuple:
          Transformed inputs.
  
          * **X_fair_train** (pandas.DataFrame) -- Transformed training
            data.
          * **y_fair_train** (array-like) -- Transformed training labels.
          * **X_fair_test** (pandas.DataFrame) -- Transformed test data.
code: def fit_transform(self, X_train, y_train, X_test):
      """Remove bias from the given dataset by fair adaptation.
  
      Args:
          X_train (pandas.DataFrame): Training data frame (including the
              protected attribute).
          y_train (pandas.Series): Training labels.
          X_test (pandas.DataFrame): Test data frame (including the protected
              attribute).
  
      Returns:
          tuple:
              Transformed inputs.
  
              * **X_fair_train** (pandas.DataFrame) -- Transformed training
                data.
              * **y_fair_train** (array-like) -- Transformed training labels.
              * **X_fair_test** (pandas.DataFrame) -- Transformed test data.
  
      """
      # merge X_train and y_train
      df_train = pd.concat([X_train, y_train], axis=1)
      groups, self.prot_attr_ = check_groups(
          X_train, self.prot_attr, ensure_binary=True
      )
      self.groups_ = np.unique(groups)
  
      wrapper = osp.join(
          osp.dirname(osp.abspath(__file__)), "fairadapt.R"
      )
      robjects.r.source(wrapper)
      FairAdapt_R = robjects.r["wrapper"]
      # convert to Pandas with a local converter
      with localconverter(
          robjects.default_converter + pandas2ri.converter
      ):
          train_data = robjects.conversion.py2rpy(df_train)
          test_data = robjects.conversion.py2rpy(X_test)
          adj_mat = robjects.conversion.py2rpy(self.adj_mat)
  
      # run FairAdapt in R
      res = FairAdapt_R(
          train_data=train_data,
          test_data=test_data,
          adj_mat=adj_mat,
          prot_attr=self.prot_attr_,
          outcome=y_train.name,
      )
  
      with localconverter(
          robjects.default_converter + pandas2ri.converter
      ):
          X_fair_train = robjects.conversion.rpy2py(res.rx2("train"))
          X_fair_test = robjects.conversion.rpy2py(res.rx2("test"))
      X_fair_train.columns = [y_train.name] + X_train.columns.tolist()
      y_fair_train = X_fair_train.pop(y_train.name)
      X_fair_test.columns = X_test.columns
  
      return X_fair_train, y_fair_train, X_fair_test
  
file_path: AIF360/aif360/sklearn/preprocessing/fairadapt.py
imports: import os.path
  import pandas
  import numpy
  from sklearn.base import BaseEstimator
  from aif360.sklearn.utils import check_inputs, check_groups
label_desc: Use image node_id 2 for calling the FairAdapt obj's underlying member method code with example usage: obj.fit_transform(X_train, y_train, X_test) and returns: X_fair_train,  y_fair_train,  X_fair_test