class_docstr: Learning fair representations is a pre-processing technique that finds a
  latent representation which encodes the data well but obfuscates information
  about protected attributes [2]_.
  References:
      .. [2] R. Zemel, Y. Wu, K. Swersky, T. Pitassi, and C. Dwork,  "Learning
         Fair Representations." International Conference on Machine Learning,
         2013.
  Based on code from https://github.com/zjelveh/learning-fair-representations
docstr: Compute the transformation parameters that leads to fair representations.
  Args:
      dataset (BinaryLabelDataset): Dataset containing true labels.
      maxiter (int): Maximum number of iterations.
      maxfun (int): Maxinum number of function evaluations.
  Returns:
      LFR: Returns self.
code: def fit(self, dataset, maxiter=5000, maxfun=5000):
      """Compute the transformation parameters that leads to fair representations.
      Args:
          dataset (BinaryLabelDataset): Dataset containing true labels.
          maxiter (int): Maximum number of iterations.
          maxfun (int): Maxinum number of function evaluations.
      Returns:
          LFR: Returns self.
      """
      if self.seed is not None:
          np.random.seed(self.seed)
  
      num_train_samples, self.features_dim = np.shape(dataset.features)
  
      protected_attributes = np.reshape(
          dataset.protected_attributes[
              :,
              dataset.protected_attribute_names.index(
                  self.protected_attribute_name
              ),
          ],
          [-1, 1],
      )
      unprivileged_sample_ids = np.array(
          np.where(
              protected_attributes
              == self.unprivileged_group_protected_attribute_value
          )
      )[0].flatten()
      privileged_sample_ids = np.array(
          np.where(
              protected_attributes
              == self.privileged_group_protected_attribute_value
          )
      )[0].flatten()
      features_unprivileged = dataset.features[unprivileged_sample_ids]
      features_privileged = dataset.features[privileged_sample_ids]
      labels_unprivileged = dataset.labels[unprivileged_sample_ids]
      labels_privileged = dataset.labels[privileged_sample_ids]
  
      # Initialize the LFR optim objective parameters
      parameters_initialization = np.random.uniform(
          size=self.k + self.features_dim * self.k
      )
      bnd = [(0, 1)] * self.k + [
          (None, None)
      ] * self.features_dim * self.k
      lfr_helpers.LFR_optim_objective.steps = 0
  
      self.learned_model = optim.fmin_l_bfgs_b(
          lfr_helpers.LFR_optim_objective,
          x0=parameters_initialization,
          epsilon=1e-5,
          args=(
              features_unprivileged,
              features_privileged,
              labels_unprivileged[:, 0],
              labels_privileged[:, 0],
              self.k,
              self.Ax,
              self.Ay,
              self.Az,
              self.print_interval,
              self.verbose,
          ),
          bounds=bnd,
          approx_grad=True,
          maxfun=maxfun,
          maxiter=maxiter,
          disp=self.verbose,
      )[0]
      self.w = self.learned_model[: self.k]
      self.prototypes = self.learned_model[self.k :].reshape(
          (self.k, self.features_dim)
      )
  
      return self
  
file_path: AIF360/aif360/algorithms/preprocessing/lfr.py
imports: import numpy
  import scipy.optimize
  from aif360.algorithms import Transformer
  from aif360.algorithms.preprocessing.lfr_helpers import helpers
label_desc: Use image node_id 2 for calling the LFR obj's underlying member method code with example usage: obj.fit(dataset, maxiter, maxfun) and returns: self