class_docstr: Transformer for binarizing categorical and ordinal features.
  
  For use with BooleanRuleCG, LogisticRuleRegression, and LinearRuleRegression. This transformer generates binary
  features using splits in decision trees. Compared to `FeatureBinarizer`, this approach reduces the number of
  features required to produce an accurate model. The smaller feature space shortens training time and often
  simplifies rule sets.
class_docstr_tok: ["Transformer","for","binarizing","categorical","and","ordinal","features",".","For","use","with","BooleanRuleCG",",","LogisticRuleRegression",",","and","LinearRuleRegression",".","This","transformer","generates","binary","features","using","splits","in","decision","trees",".","Compared","to","`","FeatureBinarizer","`",",","this","approach","reduces","the","number","of","features","required","to","produce","an","accurate","model",".","The","smaller","feature","space","shortens","training","time","and","often","simplifies","rule","sets","."]
code: def _fit_transform_like_feature_binarizer(
      self, X: DataFrame
  ) -> DataFrame:
      # Initialize
      maps = {}
      enc = {}
      thresh = {}
      ordinal = []
      A = DataFrame(
          index=X.index,
          columns=pd.MultiIndex.from_arrays(
              [[], [], []], names=["feature", "operation", "value"]
          ),
      )
  
      # Iterate over columns
      for c in X:
          # number of unique values
          valUniq = X[c].nunique()
  
          # Constant or binary column
          if valUniq <= 2:
              # Mapping to 0, 1
              maps[c] = pd.Series(
                  range(valUniq), index=np.sort(X[c].dropna().unique())
              )
              A[(str(c), "", "")] = X[c].map(maps[c])
  
          # Categorical column
          elif (c in self.colCateg) or (X[c].dtype == "object"):
              # In the past, OneHotEncoder did not support NaN. Now it does, but it doesn't logically work for this
              # scenario. Check for NaNs and throw the same exception manually.
              if X[[c]].isna().any()[0]:
                  raise ValueError("Categorical input contains NaN.")
              # OneHotEncoder object
              enc[c] = OneHotEncoder(
                  sparse=False, dtype=int, handle_unknown="ignore"
              )
              # Fit to observed categories
              enc[c].fit(X[[c]])
              # Apply OneHotEncoder
              Anew = enc[c].transform(X[[c]])
              # Original FeatureBinarizer converts all values to str. This class preserves type to be used
              # during transform.
              Anew = DataFrame(
                  Anew, index=X.index, columns=enc[c].categories_[0]
              )
              Anew.columns = pd.MultiIndex.from_product(
                  [[str(c)], ["=="], Anew.columns]
              )
              # Concatenate
              A = pd.concat([A, Anew], axis=1)
  
          # Ordinal column
          elif np.issubdtype(X[c].dtype, np.integer) | np.issubdtype(
              X[c].dtype, np.floating
          ):
              # Unlike FeaturBinarizer, just append the original ordinal column. It will be fit by the
              # DecisionTreeClassifier.
              Anew = DataFrame(
                  X[c].to_numpy(),  # Required
                  columns=pd.MultiIndex.from_arrays(
                      [[c], ["<="], [0.0]],
                      names=["feature", "operation", "value"],
                  ),
                  index=X.index,
              )
              A = pd.concat([A, Anew], axis=1)
              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.ordinal = ordinal
  
      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 2 for calling the FeatureBinarizerFromTrees obj's underlying member method code with example usage: obj._fit_transform_like_feature_binarizer(X) and returns: A