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","."]
docstr: Binarize features. Binary features are sorted name-operation-value.
  
  Args:
      X (DataFrame): Original features
  Returns:
      A (DataFrame): Binarized features with MultiIndex column labels
      Xstd (DataFrame, optional): Standardized ordinal features
docstr_tok: ["Binarize","features",".","Binary","features","are","sorted","name-operation-value",".","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: DataFrame
  ) -> Union[DataFrame, Tuple[DataFrame, DataFrame]]:
      """Binarize features. Binary features are sorted name-operation-value.
  
      Args:
          X (DataFrame): Original features
      Returns:
          A (DataFrame): Binarized features with MultiIndex column labels
          Xstd (DataFrame, optional): Standardized ordinal features
      """
  
      result: DataFrame = DataFrame(
          np.zeros(
              (X.shape[0], len(self.features)), dtype=int
          ),  # Type consistent with original FeatureBinarizer
          columns=self.features,
          index=X.index,
      )
  
      # Using to_numpy() speeds up the overall transform by more than 2x because indices aren't created/aligned.
      # Futhermore, using numpy raises warnings for NaN/None values which is what we want here.
      for feature, test, value in result.columns:
          if test == "<=":
              v = X[feature].to_numpy() <= value
          elif test == ">":
              v = X[feature].to_numpy() > value
          elif test == "==":
              v = X[feature].to_numpy() == value
          elif test == "!=":
              v = X[feature].to_numpy() != value
          elif test == "":
              v = X[feature].to_numpy() == self.maps[feature].index[1]
          elif test == "not":
              v = X[feature].to_numpy() == self.maps[feature].index[0]
          else:
              raise RuntimeError(
                  f"Test operation '{test}' not supported."
              )
  
          # Faster to replace column with numpy because there is no index to align/join
          result[(feature, test, value)] = v.astype(int)
  
      if self.threshStr:
          result.columns = result.columns.set_levels(
              levels=result.columns.levels[2].astype(str), level="value"
          )
  
      # This is taken from FeatureBinarizer.
      if self.returnOrd:
          # Standardize ordinal features
          Xstd = self.scaler.transform(X[self.ordinal])
          Xstd = DataFrame(Xstd, index=X.index, columns=self.ordinal)
          return result, Xstd
      else:
          return result
  
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 4 for calling the FeatureBinarizerFromTrees obj's underlying member method code with example usage: obj.transform(X) and returns: result,  Xstd, result