class_docstr: Transformer for binarizing categorical and ordinal (including continuous) features.
  
  Note that all features are converted into binary variables before learning Boolean rules.
docstr: Fit to data, including the learning of thresholds where appropriate.
  
  Sets the following internal variables:
  * `maps` = dictionary of mappings for unary/binary columns
  * `enc` = dictionary of OneHotEncoders for categorical columns
  * `thresh` = dictionary of lists of thresholds for ordinal columns
  * `NaN` = list of ordinal columns containing NaN values
  
  :param X: Original features as a Pandas Dataframe
  :type X: pd.DataFrame
docstr_tok: ["Fit","to","data",",","including","the","learning","of","thresholds","where","appropriate",".","Sets","the","following","internal","variables",":","*","`","maps","`","=","dictionary","of","mappings","for","unary\/binary","columns","*","`","enc","`","=","dictionary","of","OneHotEncoders","for","categorical","columns","*","`","thresh","`","=","dictionary","of","lists","of","thresholds","for","ordinal","columns","*","`","NaN","`","=","list","of","ordinal","columns","containing","NaN","values",":","param","X",":","Original","features","as","a","Pandas","Dataframe",":","type","X",":","pd.DataFrame"]
code: def fit(self, X):
      """
      Fit to data, including the learning of thresholds where appropriate.
  
      Sets the following internal variables:
      * `maps` = dictionary of mappings for unary/binary columns
      * `enc` = dictionary of OneHotEncoders for categorical columns
      * `thresh` = dictionary of lists of thresholds for ordinal columns
      * `NaN` = list of ordinal columns containing NaN values
  
      :param X: Original features as a Pandas Dataframe
      :type X: pd.DataFrame
      """
      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 = []
  
      # 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].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.dtype(int).type
          ) | np.issubdtype(data[c].dtype, np.dtype(float).type):
              # 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
              elif c in self.threshOverride.keys():
                  thresh[c] = self.threshOverride[c]
              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)
  
          else:
              print(
                  (
                      "Skipping column '"
                      + str(c)
                      + "': data type cannot be handled"
                  )
              )
              continue
  
      self.maps = maps
      self.enc = enc
      self.thresh = thresh
      self.NaN = NaN
      return self
  
file_path: dowhy/dowhy/causal_refuters/overrule/BCS/load_process_data_BCS.py
imports: from typing import Dict, List
  import numpy
  import pandas
  from sklearn.base import TransformerMixin
  from sklearn.preprocessing import OneHotEncoder
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