class_docstr: Transformer for binarizing categorical and ordinal features.
  
  For use with BooleanRuleCG, LogisticRuleRegression and LinearRuleRegression
class_docstr_tok: ["Transformer","for","binarizing","categorical","and","ordinal","features",".","For","use","with","BooleanRuleCG",",","LogisticRuleRegression","and","LinearRuleRegression"]
docstr: Binarize features
  
  Args:
      X (DataFrame): Original features
  Returns:
      A (DataFrame): Binarized features with MultiIndex column labels
      Xstd (DataFrame, optional): Standardized ordinal features
docstr_tok: ["Binarize","features","Args",":","X","(","DataFrame",")",":","Original","features","Returns",":","A","(","DataFrame",")",":","Binarized","features","with","MultiIndex","column","labels","Xstd","(","DataFrame",",","optional",")",":","Standardized","ordinal","features"]
code: def transform(self, X):
      """Binarize features
  
      Args:
          X (DataFrame): Original features
      Returns:
          A (DataFrame): Binarized features with MultiIndex column labels
          Xstd (DataFrame, optional): Standardized ordinal features
      """
      data = X
      maps = self.maps
      enc = self.enc
      thresh = self.thresh
      NaN = self.NaN
  
      # Initialize dataframe
      A = pd.DataFrame(
          index=data.index,
          columns=pd.MultiIndex.from_arrays(
              [[], [], []], names=["feature", "operation", "value"]
          ),
      )
  
      # Iterate over columns
      for c in data:
          # Constant or binary column
          if c in maps:
              # Rename values to 0, 1
              colName = (
                  (str(c), "!=", str(maps[c].index[0]))
                  if len(maps[c]) == 1
                  else (str(c), "==", str(maps[c].index[1]))
              )
              A[colName] = data[c].map(maps[c]).astype(int)
              if self.negations:
                  A[(str(c), "==", str(maps[c].index[0]))] = (
                      1 - A[colName]
                  )
  
          # Categorical column
          elif c in enc:
              # Apply OneHotEncoder
              Anew = enc[c].transform(data[[c]])
              Anew = pd.DataFrame(
                  Anew,
                  index=data.index,
                  columns=enc[c].categories_[0].astype(str),
              )
              if self.negations:
                  # Append negations
                  Anew = pd.concat(
                      [Anew, 1 - Anew],
                      axis=1,
                      keys=[(str(c), "=="), (str(c), "!=")],
                  )
              else:
                  Anew.columns = pd.MultiIndex.from_product(
                      [[str(c)], ["=="], Anew.columns]
                  )
              # Concatenate
              A = pd.concat([A, Anew], axis=1)
  
          # Ordinal column
          elif c in thresh:
              # Threshold values to produce binary arrays
              Anew = (
                  data[c].values[:, np.newaxis] <= thresh[c]
              ).astype(int)
              if self.negations:
                  # Append negations
                  Anew = np.concatenate((Anew, 1 - Anew), axis=1)
                  ops = ["<=", ">"]
              else:
                  ops = ["<="]
              # Convert to dataframe with column labels
              if self.threshStr:
                  Anew = pd.DataFrame(
                      Anew,
                      index=data.index,
                      columns=pd.MultiIndex.from_product(
                          [[str(c)], ops, thresh[c].astype(str)]
                      ),
                  )
              else:
                  Anew = pd.DataFrame(
                      Anew,
                      index=data.index,
                      columns=pd.MultiIndex.from_product(
                          [[str(c)], ops, thresh[c]]
                      ),
                  )
              if c in NaN:
                  # Ensure that rows corresponding to NaN values are zeroed out
                  indNull = data[c].isnull()
                  Anew.loc[indNull] = 0
                  # Add NaN indicator column
                  Anew[(str(c), "==", "NaN")] = indNull.astype(int)
                  if self.negations:
                      Anew[(str(c), "!=", "NaN")] = (~indNull).astype(
                          int
                      )
              # Concatenate
              A = pd.concat([A, Anew], axis=1)
  
          else:
              print(
                  (
                      "Skipping column '"
                      + str(c)
                      + "': data type cannot be handled"
                  )
              )
              continue
  
      if self.returnOrd:
          # Standardize ordinal features
          Xstd = self.scaler.transform(data[self.ordinal])
          Xstd = pd.DataFrame(
              Xstd, index=data.index, columns=self.ordinal
          )
          # Fill NaN with mean (which is now zero)
          Xstd.fillna(0, inplace=True)
          return A, Xstd
      else:
          return A
  
file_path: AIX360/aix360/algorithms/rbm/features.py
imports: from typing import Optional, Tuple, Union
  import numpy
  import pandas
  from numpy import ndarray
  from pandas import DataFrame, Series
  from sklearn.base import TransformerMixin
  from sklearn.preprocessing import OneHotEncoder, StandardScaler
  from sklearn.tree import DecisionTreeClassifier
label_desc: Use image node_id 3 for calling the FeatureBinarizer obj's underlying member method code with example usage: obj.transform(X) and returns: A,  Xstd, A