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: Fit FeatureBinarizer to data
  
  Args:
      X (DataFrame): Original features
  Returns:
      FeatureBinarizer: Self
      self.maps (dict): Mappings for unary/binary columns
      self.enc (dict): OneHotEncoders for categorical columns
      self.thresh (dict(array)): Thresholds for ordinal columns
      self.NaN (list): Ordinal columns containing NaN values
      self.ordinal (list): Ordinal columns
      self.scaler (StandardScaler): StandardScaler for ordinal columns
docstr_tok: ["Fit","FeatureBinarizer","to","data","Args",":","X","(","DataFrame",")",":","Original","features","Returns",":","FeatureBinarizer",":","Self","self.maps","(","dict",")",":","Mappings","for","unary\/binary","columns","self.enc","(","dict",")",":","OneHotEncoders","for","categorical","columns","self.thresh","(","dict","(","array",")",")",":","Thresholds","for","ordinal","columns","self.NaN","(","list",")",":","Ordinal","columns","containing","NaN","values","self.ordinal","(","list",")",":","Ordinal","columns","self.scaler","(","StandardScaler",")",":","StandardScaler","for","ordinal","columns"]
code: def fit(self, X):
      """Fit FeatureBinarizer to data
  
      Args:
          X (DataFrame): Original features
      Returns:
          FeatureBinarizer: Self
          self.maps (dict): Mappings for unary/binary columns
          self.enc (dict): OneHotEncoders for categorical columns
          self.thresh (dict(array)): Thresholds for ordinal columns
          self.NaN (list): Ordinal columns containing NaN values
          self.ordinal (list): Ordinal columns
          self.scaler (StandardScaler): StandardScaler for ordinal columns
      """
      data = X
      # Quantile probabilities
      quantProb = np.linspace(
          1.0 / (self.numThresh + 1.0),
          self.numThresh / (self.numThresh + 1.0),
          self.numThresh,
      )
      # Initialize
      maps = {}
      enc = {}
      thresh = {}
      NaN = []
      if self.returnOrd:
          ordinal = []
  
      # Iterate over columns
      for c in data:
          # number of unique values
          valUniq = data[c].nunique()
  
          # Constant or binary column
          if valUniq <= 2:
              # Mapping to 0, 1
              maps[c] = pd.Series(
                  range(valUniq),
                  index=np.sort(data[c].dropna().unique()),
              )
  
          # Categorical column
          elif (c in self.colCateg) or (data[c].dtype == "object"):
              # OneHotEncoder object
              enc[c] = OneHotEncoder(
                  sparse=False, dtype=int, handle_unknown="ignore"
              )
              # Fit to observed categories
              enc[c].fit(data[[c]])
  
          # Ordinal column
          elif np.issubdtype(data[c].dtype, np.integer) | np.issubdtype(
              data[c].dtype, np.floating
          ):
              # Few unique values
              if valUniq <= self.numThresh + 1:
                  # Thresholds are sorted unique values excluding maximum
                  thresh[c] = np.sort(data[c].unique())[:-1]
              # Many unique values
              else:
                  # Thresholds are quantiles excluding repetitions
                  thresh[c] = data[c].quantile(q=quantProb).unique()
              if data[c].isnull().any():
                  # Contains NaN values
                  NaN.append(c)
              if self.returnOrd:
                  ordinal.append(c)
  
          else:
              print(
                  (
                      "Skipping column '"
                      + str(c)
                      + "': data type cannot be handled"
                  )
              )
              continue
  
      self.maps = maps
      self.enc = enc
      self.thresh = thresh
      self.NaN = NaN
      if self.returnOrd:
          self.ordinal = ordinal
          # Fit StandardScaler to ordinal features
          self.scaler = StandardScaler().fit(data[ordinal])
      return self
  
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 2 for calling the FeatureBinarizer obj's underlying member method code with example usage: obj.fit(X) and returns: self