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: Args:
      colCateg (list): Categorical features ('object' dtype automatically treated as categorical). These features
          are one-hot-encoded.
      treeNum (int): Number of trees to fit. Setting 'treeNum' to a value greater than one usually produces a
          larger variety of output features.
      treeDepth (int): The maximum depth of the tree. Setting 'treeDepth=None' grows a tree without limit.
          Larger depth values produce more output features. Corresponds to parameter 'max_depth' in
          DecisionTreeClassifier.
      treeFeatureSelection (float, str): When building a tree, the input features are randomly permuted at
          each split. This parameter specifies how many input features are considered at each split. By default,
          this parameter is set to 'None' which indicates that all features should be considered at every split.
          Other possible values are 'sqrt', 'log2', or a float that indicates the proportion of features to
          select at every split (e.g. 0.5 would randomly select half of the input features at every split).
          To create a wide variety of output features, or to sift through a very large number of features,
          increase 'treeNum' and set 'treeFeatureSelection="sqrt"'. Corresponds to 'max_features' in
          DecisionTreeClassifier.
      treeKwargs (dict): A dictionary of parameters to pass to the scikit-learn DecisionTreeClassifier during
          fitting.
      threshRound (int): Round threshold values by this number of decimal places. This parameter can be used
          to prevent similar thresholds from generating separate binarized features. E.g., if 'threshRound=2',
          only one binarized feature will be generated for thresholds 0.009 and 0.01. Setting 'threshRound=None'
          will disable rounding.
      threshStr (bool): Convert threshold values to strings, including categorical values, in transformed
          data frame's index.
      returnOrd (bool): Return a standardized data frame for ordinal features (both discrete and continuous)
          during transformation in addition to the binarized data frame.
      randomState (int): Random state for decision tree.
docstr_tok: ["Args",":","colCateg","(","list",")",":","Categorical","features","(","'object","'","dtype","automatically","treated","as","categorical",")",".","These","features","are","one-hot-encoded",".","treeNum","(","int",")",":","Number","of","trees","to","fit",".","Setting","'treeNum","'","to","a","value","greater","than","one","usually","produces","a","larger","variety","of","output","features",".","treeDepth","(","int",")",":","The","maximum","depth","of","the","tree",".","Setting","'treeDepth=None","'","grows","a","tree","without","limit",".","Larger","depth","values","produce","more","output","features",".","Corresponds","to","parameter","'max_depth","'","in","DecisionTreeClassifier",".","treeFeatureSelection","(","float",",","str",")",":","When","building","a","tree",",","the","input","features","are","randomly","permuted","at","each","split",".","This","parameter","specifies","how","many","input","features","are","considered","at","each","split",".","By","default",",","this","parameter","is","set","to","'None","'","which","indicates","that","all","features","should","be","considered","at","every","split",".","Other","possible","values","are","'sqrt","'",",","'log2","'",",","or","a","float","that","indicates","the","proportion","of","features","to","select","at","every","split","(","e.g",".","0.5","would","randomly","select","half","of","the","input","features","at","every","split",")",".","To","create","a","wide","variety","of","output","features",",","or","to","sift","through","a","very","large","number","of","features",",","increase","'treeNum","'","and","set","'treeFeatureSelection=","''","sqrt","''","'",".","Corresponds","to","'max_features","'","in","DecisionTreeClassifier",".","treeKwargs","(","dict",")",":","A","dictionary","of","parameters","to","pass","to","the","scikit-learn","DecisionTreeClassifier","during","fitting",".","threshRound","(","int",")",":","Round","threshold","values","by","this","number","of","decimal","places",".","This","parameter","can","be","used","to","prevent","similar","thresholds","from","generating","separate","binarized","features",".","E.g.",",","if","'threshRound=2","'",",","only","one","binarized","feature","will","be","generated","for","thresholds","0.009","and","0.01",".","Setting","'threshRound=None'","will","disable","rounding",".","threshStr","(","bool",")",":","Convert","threshold","values","to","strings",",","including","categorical","values",",","in","transformed","data","frame","'s","index",".","returnOrd","(","bool",")",":","Return","a","standardized","data","frame","for","ordinal","features","(","both","discrete","and","continuous",")","during","transformation","in","addition","to","the","binarized","data","frame",".","randomState","(","int",")",":","Random","state","for","decision","tree","."]
code: def __init__(
      self,
      colCateg: list = None,
      treeNum: int = 1,
      treeDepth: Optional[int] = 4,
      treeFeatureSelection: Union[str, float, None] = None,
      treeKwargs: dict = None,
      threshRound: Optional[int] = 6,
      threshStr: bool = False,
      returnOrd: bool = False,
      randomState: int = None,
      **kwargs,
  ):
      """
      Args:
          colCateg (list): Categorical features ('object' dtype automatically treated as categorical). These features
              are one-hot-encoded.
          treeNum (int): Number of trees to fit. Setting 'treeNum' to a value greater than one usually produces a
              larger variety of output features.
          treeDepth (int): The maximum depth of the tree. Setting 'treeDepth=None' grows a tree without limit.
              Larger depth values produce more output features. Corresponds to parameter 'max_depth' in
              DecisionTreeClassifier.
          treeFeatureSelection (float, str): When building a tree, the input features are randomly permuted at
              each split. This parameter specifies how many input features are considered at each split. By default,
              this parameter is set to 'None' which indicates that all features should be considered at every split.
              Other possible values are 'sqrt', 'log2', or a float that indicates the proportion of features to
              select at every split (e.g. 0.5 would randomly select half of the input features at every split).
              To create a wide variety of output features, or to sift through a very large number of features,
              increase 'treeNum' and set 'treeFeatureSelection="sqrt"'. Corresponds to 'max_features' in
              DecisionTreeClassifier.
          treeKwargs (dict): A dictionary of parameters to pass to the scikit-learn DecisionTreeClassifier during
              fitting.
          threshRound (int): Round threshold values by this number of decimal places. This parameter can be used
              to prevent similar thresholds from generating separate binarized features. E.g., if 'threshRound=2',
              only one binarized feature will be generated for thresholds 0.009 and 0.01. Setting 'threshRound=None'
              will disable rounding.
          threshStr (bool): Convert threshold values to strings, including categorical values, in transformed
              data frame's index.
          returnOrd (bool): Return a standardized data frame for ordinal features (both discrete and continuous)
              during transformation in addition to the binarized data frame.
          randomState (int): Random state for decision tree.
      """
  
      # Categorical columns
      if colCateg is None:
          self.colCateg = []
      elif type(colCateg) is Series:
          self.colCateg = colCateg.to_list()
      elif type(colCateg) is not list:
          self.colCateg = [colCateg]
      else:
          self.colCateg = colCateg
  
      # Number of trees
      if (
          (treeNum is None)
          or (treeNum < 1)
          or (int(treeNum) != treeNum)
      ):
          raise ValueError(
              "The value for 'treeNum' must be an integer value greater than zero."
          )
      self.treeNum = int(treeNum)
  
      # Tree kwargs
      if treeKwargs is None:
          treeKwargs = dict(max_features=None)
      elif "max_features" not in treeKwargs:
          treeKwargs["max_features"] = None
  
      # Tree depth
      if treeDepth is not None:
          if (treeDepth < 1) or (int(treeDepth) != treeDepth):
              raise ValueError(
                  "The value for 'treeDepth' must be None or an integer value greater than zero."
              )
          treeKwargs["max_depth"] = treeDepth
      elif "max_depth" in treeKwargs:
          treeDepth = treeKwargs["max_depth"]
      self.treeDepth = treeDepth
  
      # Tree feature selection
      if treeFeatureSelection is not None:
          if isinstance(treeFeatureSelection, str):
              error = treeFeatureSelection not in (
                  "auto",
                  "sqrt",
                  "log2",
              )
          elif isinstance(treeFeatureSelection, (float, int)):
              error = (treeFeatureSelection <= 0.0) or (
                  treeFeatureSelection > 1.0
              )
          else:
              error = True
          if error:
              raise ValueError(
                  "Valid values for 'treeFeatureSelection' are None, 'auto', 'sqrt', 'log2', or "
                  "a value in interval (0, 1]."
              )
          treeKwargs["max_features"] = treeFeatureSelection
      elif "max_features" in treeKwargs:
          treeFeatureSelection = treeKwargs["max_features"]
      self.treeFeatureSelection = treeFeatureSelection
  
      # Tree kwargs
      self.treeKwargs = treeKwargs
  
      # Random state
      self.randomState = randomState
  
      # Rounding for ordinal values
      if (threshRound is not None) and (threshRound < 0):
          raise ValueError(
              "The value for 'threshRound' must be None, or zero, or greater than zero."
          )
      self.threshRound = threshRound
  
      # Whether to convert thresholds on ordinal features to strings
      self.threshStr = threshStr
  
      # Whether to convert thresholds on ordinal features to strings.  Also return standardized ordinal features
      # during transformation
      self.returnOrd = returnOrd
  
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 1 to create a new FeatureBinarizerFromTrees object from inherited base classes: TransformerMixin with example: obj = FeatureBinarizerFromTrees(colCateg, treeNum, treeDepth, treeFeatureSelection, treeKwargs, threshRound, threshStr, returnOrd, randomState)