class_docstr: Optimized preprocessing is a preprocessing technique that learns a
  probabilistic transformation that edits the features and labels in the data
  with group fairness, individual distortion, and data fidelity constraints
  and objectives [3]_.
  
  References:
      .. [3] F. P. Calmon, D. Wei, B. Vinzamuri, K. Natesan Ramamurthy, and
         K. R. Varshney. "Optimized Pre-Processing for Discrimination
         Prevention." Conference on Neural Information Processing Systems,
         2017.
  
  Based on code available at: https://github.com/fair-preprocessing/nips2017
class_docstr_tok: ["Optimized","preprocessing","is","a","preprocessing","technique","that","learns","a","probabilistic","transformation","that","edits","the","features","and","labels","in","the","data","with","group","fairness",",","individual","distortion",",","and","data","fidelity","constraints","and","objectives","[","3","]","_.","References",":","..","[","3","]","F.","P.","Calmon",",","D.","Wei",",","B.","Vinzamuri",",","K.","Natesan","Ramamurthy",",","and","K.","R.","Varshney",".","``","Optimized","Pre-Processing","for","Discrimination","Prevention",".","''","Conference","on","Neural","Information","Processing","Systems",",","2017",".","Based","on","code","available","at",":","https",":","\/\/github.com\/fair-preprocessing\/nips2017"]
docstr: Compute optimal pre-processing transformation based on distortion
  constraint.
  
  Args:
      dataset (BinaryLabelDataset): Dataset containing true labels.
      sep (str, optional): Separator for converting one-hot labels to
          categorical.
  Returns:
      OptimPreproc: Returns self.
docstr_tok: ["Compute","optimal","pre-processing","transformation","based","on","distortion","constraint",".","Args",":","dataset","(","BinaryLabelDataset",")",":","Dataset","containing","true","labels",".","sep","(","str",",","optional",")",":","Separator","for","converting","one-hot","labels","to","categorical",".","Returns",":","OptimPreproc",":","Returns","self","."]
code: def fit(self, dataset, sep="="):
      """Compute optimal pre-processing transformation based on distortion
      constraint.
  
      Args:
          dataset (BinaryLabelDataset): Dataset containing true labels.
          sep (str, optional): Separator for converting one-hot labels to
              categorical.
      Returns:
          OptimPreproc: Returns self.
      """
      if len(np.unique(dataset.instance_weights)) > 1:
          warn(
              "Optimized pre-processing will ignore instance_weights in "
              "the dataset during fit."
          )
      # Convert the dataset to a dataframe and preprocess
      df, _ = dataset.convert_to_dataframe(
          de_dummy_code=True, sep=sep, set_category=True
      )
  
      # Subset the protected attribute names and attribute values from
      # input parameters
      self.protected_attribute_names = dataset.protected_attribute_names
      self.privileged_protected_attributes = (
          dataset.privileged_protected_attributes
      )
      self.unprivileged_protected_attributes = (
          dataset.unprivileged_protected_attributes
      )
  
      # Feature names
      self.Y_feature_names = dataset.label_names
      self.X_feature_names = [
          n
          for n in df.columns.tolist()
          if n not in self.Y_feature_names
          and n not in self.protected_attribute_names
      ]
      self.feature_names = (
          self.X_feature_names
          + self.Y_feature_names
          + self.protected_attribute_names
      )
  
      # initialize a new OptTools object
      self.OpT = self.optimizer(df=df, features=self.feature_names)
  
      # Set features
      self.OpT.set_features(
          D=self.protected_attribute_names,
          X=self.X_feature_names,
          Y=self.Y_feature_names,
      )
  
      # Set Distortion
      self.OpT.set_distortion(
          self.optim_options["distortion_fun"],
          clist=self.optim_options["clist"],
      )
  
      # solve optimization for previous parameters
      self.OpT.optimize(
          epsilon=self.optim_options["epsilon"],
          dlist=self.optim_options["dlist"],
          verbose=self.verbose,
      )
  
      # Compute marginals
      self.OpT.compute_marginals()
  
      return self
  
file_path: AIF360/aif360/algorithms/preprocessing/optim_preproc.py
imports: from warnings import warn
  import numpy
  import pandas
  from aif360.algorithms import Transformer
  from aif360.datasets import BinaryLabelDataset
label_desc: Use image node_id 2 for calling the OptimPreproc obj's underlying member method code with example usage: obj.fit(dataset, sep) and returns: self