class_docstr: Base class for the tree ensemble builder class.  This should be instantiated
  either through the :py:class:`TreeEnsembleRegressor` or
  :py:class:`TreeEnsembleClassifier` classes.
class_docstr_tok: ["Base","class","for","the","tree","ensemble","builder","class",".","This","should","be","instantiated","either","through","the",":","py",":","class",":","`","TreeEnsembleRegressor","`","or",":","py",":","class",":","`","TreeEnsembleClassifier","`","classes","."]
docstr: Add a branch node to the tree ensemble.
  
  Parameters
  ----------
  tree_id: int
      ID of the tree to add the node to.
  
  node_id: int
      ID of the node within the tree.
  
  feature_index: int
      Index of the feature in the input being split on.
  
  feature_value: double or int
      The value used in the feature comparison determining the traversal
      direction from this node.
  
  branch_mode: str
      Branch mode of the node, specifying the condition under which the node
      referenced by ``true_child_id`` is called next.
  
      Must be one of the following:
  
        - ``"BranchOnValueLessThanEqual"``. Traverse to node ``true_child_id``
          if ``input[feature_index] <= feature_value``, and ``false_child_id``
          otherwise.
  
        - ``"BranchOnValueLessThan"``. Traverse to node ``true_child_id``
          if ``input[feature_index] < feature_value``, and ``false_child_id``
          otherwise.
  
        - ``"BranchOnValueGreaterThanEqual"``. Traverse to node ``true_child_id``
          if ``input[feature_index] >= feature_value``, and ``false_child_id``
          otherwise.
  
        - ``"BranchOnValueGreaterThan"``. Traverse to node ``true_child_id``
          if ``input[feature_index] > feature_value``, and ``false_child_id``
          otherwise.
  
        - ``"BranchOnValueEqual"``. Traverse to node ``true_child_id``
          if ``input[feature_index] == feature_value``, and ``false_child_id``
          otherwise.
  
        - ``"BranchOnValueNotEqual"``. Traverse to node ``true_child_id``
          if ``input[feature_index] != feature_value``, and ``false_child_id``
          otherwise.
  
  true_child_id: int
      ID of the child under the true condition of the split.  An error will
      be raised at model validation if this does not match the ``node_id``
      of a node instantiated by ``add_branch_node`` or ``add_leaf_node`` within
      this ``tree_id``.
  
  false_child_id: int
      ID of the child under the false condition of the split.  An error will
      be raised at model validation if this does not match the ``node_id``
      of a node instantiated by ``add_branch_node`` or ``add_leaf_node`` within
      this ``tree_id``.
  
  relative_hit_rate: float [optional]
      When the model is converted compiled by CoreML, this gives hints to
      Core ML about which node is more likely to be hit on evaluation,
      allowing for additional optimizations. The values can be on any scale,
      with the values between child nodes being compared relative to each
      other.
  
  missing_value_tracks_true_child: bool [optional]
      If the training data contains NaN values or missing values, then this
      flag determines which direction a NaN value traverses.
docstr_tok: ["Add","a","branch","node","to","the","tree","ensemble",".","Parameters","--","--","--","--","--","tree_id",":","int","ID","of","the","tree","to","add","the","node","to",".","node_id",":","int","ID","of","the","node","within","the","tree",".","feature_index",":","int","Index","of","the","feature","in","the","input","being","split","on",".","feature_value",":","double","or","int","The","value","used","in","the","feature","comparison","determining","the","traversal","direction","from","this","node",".","branch_mode",":","str","Branch","mode","of","the","node",",","specifying","the","condition","under","which","the","node","referenced","by","``","true_child_id","``","is","called","next",".","Must","be","one","of","the","following",":","-","``","``","BranchOnValueLessThanEqual","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]","<","=","feature_value","``",",","and","``","false_child_id","``","otherwise",".","-","``","``","BranchOnValueLessThan","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]","<","feature_value","``",",","and","``","false_child_id","``","otherwise",".","-","``","``","BranchOnValueGreaterThanEqual","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]",">","=","feature_value","``",",","and","``","false_child_id","``","otherwise",".","-","``","``","BranchOnValueGreaterThan","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]",">","feature_value","``",",","and","``","false_child_id","``","otherwise",".","-","``","``","BranchOnValueEqual","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]","==","feature_value","``",",","and","``","false_child_id","``","otherwise",".","-","``","``","BranchOnValueNotEqual","''","``",".","Traverse","to","node","``","true_child_id","``","if","``","input","[","feature_index","]","!","=","feature_value","``",",","and","``","false_child_id","``","otherwise",".","true_child_id",":","int","ID","of","the","child","under","the","true","condition","of","the","split",".","An","error","will","be","raised","at","model","validation","if","this","does","not","match","the","``","node_id","``","of","a","node","instantiated","by","``","add_branch_node","``","or","``","add_leaf_node","``","within","this","``","tree_id","``",".","false_child_id",":","int","ID","of","the","child","under","the","false","condition","of","the","split",".","An","error","will","be","raised","at","model","validation","if","this","does","not","match","the","``","node_id","``","of","a","node","instantiated","by","``","add_branch_node","``","or","``","add_leaf_node","``","within","this","``","tree_id","``",".","relative_hit_rate",":","float","[","optional","]","When","the","model","is","converted","compiled","by","CoreML",",","this","gives","hints","to","Core","ML","about","which","node","is","more","likely","to","be","hit","on","evaluation",",","allowing","for","additional","optimizations",".","The","values","can","be","on","any","scale",",","with","the","values","between","child","nodes","being","compared","relative","to","each","other",".","missing_value_tracks_true_child",":","bool","[","optional","]","If","the","training","data","contains","NaN","values","or","missing","values",",","then","this","flag","determines","which","direction","a","NaN","value","traverses","."]
code: def add_branch_node(
      self,
      tree_id,
      node_id,
      feature_index,
      feature_value,
      branch_mode,
      true_child_id,
      false_child_id,
      relative_hit_rate=None,
      missing_value_tracks_true_child=False,
  ):
      """
      Add a branch node to the tree ensemble.
  
      Parameters
      ----------
      tree_id: int
          ID of the tree to add the node to.
  
      node_id: int
          ID of the node within the tree.
  
      feature_index: int
          Index of the feature in the input being split on.
  
      feature_value: double or int
          The value used in the feature comparison determining the traversal
          direction from this node.
  
      branch_mode: str
          Branch mode of the node, specifying the condition under which the node
          referenced by ``true_child_id`` is called next.
  
          Must be one of the following:
  
            - ``"BranchOnValueLessThanEqual"``. Traverse to node ``true_child_id``
              if ``input[feature_index] <= feature_value``, and ``false_child_id``
              otherwise.
  
            - ``"BranchOnValueLessThan"``. Traverse to node ``true_child_id``
              if ``input[feature_index] < feature_value``, and ``false_child_id``
              otherwise.
  
            - ``"BranchOnValueGreaterThanEqual"``. Traverse to node ``true_child_id``
              if ``input[feature_index] >= feature_value``, and ``false_child_id``
              otherwise.
  
            - ``"BranchOnValueGreaterThan"``. Traverse to node ``true_child_id``
              if ``input[feature_index] > feature_value``, and ``false_child_id``
              otherwise.
  
            - ``"BranchOnValueEqual"``. Traverse to node ``true_child_id``
              if ``input[feature_index] == feature_value``, and ``false_child_id``
              otherwise.
  
            - ``"BranchOnValueNotEqual"``. Traverse to node ``true_child_id``
              if ``input[feature_index] != feature_value``, and ``false_child_id``
              otherwise.
  
      true_child_id: int
          ID of the child under the true condition of the split.  An error will
          be raised at model validation if this does not match the ``node_id``
          of a node instantiated by ``add_branch_node`` or ``add_leaf_node`` within
          this ``tree_id``.
  
      false_child_id: int
          ID of the child under the false condition of the split.  An error will
          be raised at model validation if this does not match the ``node_id``
          of a node instantiated by ``add_branch_node`` or ``add_leaf_node`` within
          this ``tree_id``.
  
      relative_hit_rate: float [optional]
          When the model is converted compiled by CoreML, this gives hints to
          Core ML about which node is more likely to be hit on evaluation,
          allowing for additional optimizations. The values can be on any scale,
          with the values between child nodes being compared relative to each
          other.
  
      missing_value_tracks_true_child: bool [optional]
          If the training data contains NaN values or missing values, then this
          flag determines which direction a NaN value traverses.
  
      """
      spec_node = self.tree_parameters.nodes.add()
      spec_node.treeId = tree_id
      spec_node.nodeId = node_id
      spec_node.branchFeatureIndex = int(feature_index)
      spec_node.branchFeatureValue = feature_value
      spec_node.trueChildNodeId = true_child_id
      spec_node.falseChildNodeId = false_child_id
      spec_node.nodeBehavior = _TreeEnsemble_pb2.TreeEnsembleParameters.TreeNode.TreeNodeBehavior.Value(
          branch_mode
      )
  
      if relative_hit_rate is not None:
          spec_node.relativeHitRate = relative_hit_rate
      spec_node.missingValueTracksTrueChild = (
          missing_value_tracks_true_child
      )
  
file_path: coremltools/coremltools/models/tree_ensemble.py
imports: import collections
  from ..None import SPECIFICATION_VERSION
  from ..proto import Model_pb2
  from ..proto import TreeEnsemble_pb2
  from ._interface_management import set_classifier_interface_params, set_regressor_interface_params
label_desc: Use image node_id 4 for calling the TreeEnsembleBase obj's underlying member method code with example usage: obj.add_branch_node(tree_id, node_id, feature_index, feature_value, branch_mode, true_child_id, false_child_id, relative_hit_rate, missing_value_tracks_true_child) without return types