class_docstr: Represents a model of a Tree built by one of H2O's tree algorithms (GBM, Random Forest, XGBoost, Isolation Forest).
  
  The internal structure mimics the behavior of Scikit's internal tree representation and contains all the information available about every node in the graph
  (https://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html).
  It provides both human-readable output and formatting suitable for machine processing.
  
  In the fetched object, there are two representations of the graph contained:
  
  - graph-oriented representation, starting with a root node with edges
  - array/vector representation, useful for quick machine processing of the tree’s structure
  
  Every graph starts with a root node. This is an instance of H2OSplitNode and is naturally the very beginning of all decision paths in the graph.
  It points to its children, which again point to their children (unless an H2OLeafNode is hit). Nodes are always numbered from the top of the tree down to the lowest level and from left to right.
  
  At the tree level, the following information is provided:
  
  - Number of nodes in the tree
  - Model the tree belongs to
  - Tree class (if applicable)
  - Pointer to a root node for tree traversal (breadth-first, depth-first) and manual tree walking
  
  Each node in the tree is uniquely identified by an ID, regardless of its type. Each node type also has a human-readable description available. There are two types of nodes that are distinguished:
  
  - Split node
  - Leaf node
      
  **Split Node**: A split node is a single, non-terminal node with either a numerical or categorical feature split. The root node is guaranteed to be a split node, as a zero-depth tree :math:`t` of cardinality :math:`|t| = 1` contains no decisions at all. 
  Every split node consists of:
  
  1. An ID or H2O-specific node identifier 
  2. Left child node & right child node
  3. Split feature name (split column name)
  4. Split threshold (mainly for numerical splits)
  5. Categorical features split (categorical splits only)
  6. Direction of NA values (i.e. which way NA values go: left child, right child, or nowhere)
  
  **Leaf Node**: A leaf node is a single node with no children, thus being a terminal node at the end of the decision path in a tree. A leaf node consists of:
  
  1. An ID or H2O-specific node identifier 
  2. Prediction value (floating point number)
  
  :param model: The model this tree is related to.
  :param tree_number: An integer representing the order in which the tree has been built in the model.
  :param tree_class: A string representing the name of the tree's class. Specifies the class of the tree requested. Required for multi-class classification.
      The number of tree classes equals the number of levels in the categorical response column. As there is exactly one class per categorical level, the name of
      the tree's class is equal to the corresponding categorical level of the response column. For regression and binomial models, the name of the categorical level is ignored and can be omitted.
  :param plain_language_rules: (Optional) Whether to generate plain language rules. "AUTO" by default, meaning False for big trees and True for small trees.
  
  :examples:
  
  >>> from h2o.tree import H2OTree
  >>> from h2o.estimators import H2OGradientBoostingEstimator
  >>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
  >>> gbm = H2OGradientBoostingEstimator(ntrees=1)
  >>> gbm.train(x=["Origin", "Dest"],
  ...           y="IsDepDelayed",
  ...           training_frame=airlines)
  >>> # Obtaining a tree is a matter of a single call
  >>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
  >>> tree.model_id
  >>> tree.tree_number
  >>> tree.tree_class
class_docstr_tok: ["Represents","a","model","of","a","Tree","built","by","one","of","H2O","'s","tree","algorithms","(","GBM",",","Random","Forest",",","XGBoost",",","Isolation","Forest",")",".","The","internal","structure","mimics","the","behavior","of","Scikit","'s","internal","tree","representation","and","contains","all","the","information","available","about","every","node","in","the","graph","(","https",":","\/\/scikit-learn.org\/stable\/auto_examples\/tree\/plot_unveil_tree_structure.html",")",".","It","provides","both","human-readable","output","and","formatting","suitable","for","machine","processing",".","In","the","fetched","object",",","there","are","two","representations","of","the","graph","contained",":","-","graph-oriented","representation",",","starting","with","a","root","node","with","edges","-","array\/vector","representation",",","useful","for","quick","machine","processing","of","the","tree","\u2019","s","structure","Every","graph","starts","with","a","root","node",".","This","is","an","instance","of","H2OSplitNode","and","is","naturally","the","very","beginning","of","all","decision","paths","in","the","graph",".","It","points","to","its","children",",","which","again","point","to","their","children","(","unless","an","H2OLeafNode","is","hit",")",".","Nodes","are","always","numbered","from","the","top","of","the","tree","down","to","the","lowest","level","and","from","left","to","right",".","At","the","tree","level",",","the","following","information","is","provided",":","-","Number","of","nodes","in","the","tree","-","Model","the","tree","belongs","to","-","Tree","class","(","if","applicable",")","-","Pointer","to","a","root","node","for","tree","traversal","(","breadth-first",",","depth-first",")","and","manual","tree","walking","Each","node","in","the","tree","is","uniquely","identified","by","an","ID",",","regardless","of","its","type",".","Each","node","type","also","has","a","human-readable","description","available",".","There","are","two","types","of","nodes","that","are","distinguished",":","-","Split","node","-","Leaf","node","*","*","Split","Node","*","*",":","A","split","node","is","a","single",",","non-terminal","node","with","either","a","numerical","or","categorical","feature","split",".","The","root","node","is","guaranteed","to","be","a","split","node",",","as","a","zero-depth","tree",":","math",":","`","t","`","of","cardinality",":","math",":","`","|t|","=","1","`","contains","no","decisions","at","all",".","Every","split","node","consists","of",":","1",".","An","ID","or","H2O-specific","node","identifier","2",".","Left","child","node","&","right","child","node","3",".","Split","feature","name","(","split","column","name",")","4",".","Split","threshold","(","mainly","for","numerical","splits",")","5",".","Categorical","features","split","(","categorical","splits","only",")","6",".","Direction","of","NA","values","(","i.e",".","which","way","NA","values","go",":","left","child",",","right","child",",","or","nowhere",")","*","*","Leaf","Node","*","*",":","A","leaf","node","is","a","single","node","with","no","children",",","thus","being","a","terminal","node","at","the","end","of","the","decision","path","in","a","tree",".","A","leaf","node","consists","of",":","1",".","An","ID","or","H2O-specific","node","identifier","2",".","Prediction","value","(","floating","point","number",")",":","param","model",":","The","model","this","tree","is","related","to",".",":","param","tree_number",":","An","integer","representing","the","order","in","which","the","tree","has","been","built","in","the","model",".",":","param","tree_class",":","A","string","representing","the","name","of","the","tree","'s","class",".","Specifies","the","class","of","the","tree","requested",".","Required","for","multi-class","classification",".","The","number","of","tree","classes","equals","the","number","of","levels","in","the","categorical","response","column",".","As","there","is","exactly","one","class","per","categorical","level",",","the","name","of","the","tree","'s","class","is","equal","to","the","corresponding","categorical","level","of","the","response","column",".","For","regression","and","binomial","models",",","the","name","of","the","categorical","level","is","ignored","and","can","be","omitted",".",":","param","plain_language_rules",":","(","Optional",")","Whether","to","generate","plain","language","rules",".","``","AUTO","''","by","default",",","meaning","False","for","big","trees","and","True","for","small","trees",".",":","examples",":",">",">",">","from","h2o.tree","import","H2OTree",">",">",">","from","h2o.estimators","import","H2OGradientBoostingEstimator",">",">",">","airlines","=","h2o.import_file","(","``","https",":","\/\/s3.amazonaws.com\/h2o-public-test-data\/smalldata\/airlines\/AirlinesTrain.csv","''",")",">",">",">","gbm","=","H2OGradientBoostingEstimator","(","ntrees=1",")",">",">",">","gbm.train","(","x=","[","``","Origin","''",",","``","Dest","''","]",",","...","y=","''","IsDepDelayed","''",",","...","training_frame=airlines",")",">",">",">","#","Obtaining","a","tree","is","a","matter","of","a","single","call",">",">",">","tree","=","H2OTree","(","model","=","gbm",",","tree_number","=","0",",","tree_class","=","``","NO","''",")",">",">",">","tree.model_id",">",">",">","tree.tree_number",">",">",">","tree.tree_class"]
code: def __init__(
      self,
      model,
      tree_number,
      tree_class=None,
      plain_language_rules="AUTO",
  ):
      params = {
          "model": model.model_id,
          "tree_number": tree_number,
          "tree_class": tree_class,
          "plain_language_rules": plain_language_rules,
      }
      response = h2o.api(endpoint="GET /3/Tree", data=params)
  
      self._left_children = response["left_children"]
      self._right_children = response["right_children"]
      self._node_ids = self.__extract_internal_ids(
          response["root_node_id"]
      )
      self._descriptions = response["descriptions"]
      self._model_id = model.model_id
      self._tree_number = response["tree_number"]
      self._tree_class = response["tree_class"]
      self._thresholds = self.__convert_threshold_nans(
          response["thresholds"]
      )
      self._features = response["features"]
      self._levels = self.__decode_categoricals(
          model, response["levels"]
      )
      self._nas = response["nas"]
      self._predictions = response["predictions"]
      self._root_node = self.__assemble_tree(0)
      if response["tree_decision_path"] is None:
          self._tree_decision_path = (
              "Plain language rules generation is turned off."
          )
          self._decision_paths = (
              "Plain language rules generation is turned off."
          )
      else:
          self._tree_decision_path = response["tree_decision_path"]
          self._decision_paths = response["decision_paths"]
  
      (left, right) = self.__per_node_cat_splits()
      self._left_cat_split = left
      self._right_cat_split = right
  
imports: import math
  import h2o
label_desc: Use image node_id 1 to create a new H2OTree object from inherited base classes: object with example: obj = H2OTree(model, tree_number, tree_class, plain_language_rules)