class_docstr: Tree Ensemble builder class to construct a Tree Ensemble regression model.
  
  The TreeEnsembleRegressor class constructs a Tree Ensemble model incrementally
  using methods to add branch and leaf nodes specifying the behavior of the model.
  
  Examples
  --------
  
  In the following example, the code saves the model to disk, which is a
  recommended practice but not required.
  
  .. sourcecode:: python
  
      >>> # Required inputs
      >>> import coremltools
      >>> from coremltools.models import datatypes
      >>> from coremltools.models.tree_ensemble import TreeEnsembleRegressor
      >>> import numpy as np
  
      >>> # Define input features
      >>> input_features = [("a", datatypes.Array(3)), ("b", (datatypes.Double()))]
  
      >>> # Define output_features
      >>> output_features = [("predicted_values", datatypes.Double())]
  
      >>> tm = TreeEnsembleRegressor(features = input_features, target = output_features)
  
      >>> # Split on a[2] <= 3
      >>> tm.add_branch_node(0, 0, 2, 3, "BranchOnValueLessThanEqual", 1, 2)
  
      >>> # Add leaf to the true branch of node 0 that subtracts 1.
      >>> tm.add_leaf_node(0, 1, -1)
  
      >>> # Add split on b == 0 to the false branch of node 0, which is index 3
      >>> tm.add_branch_node(0, 2, 3, 0, "BranchOnValueEqual", 3, 4)
  
      >>> # Add leaf to the true branch of node 2 that adds 1 to the result.
      >>> tm.add_leaf_node(0, 3, 1)
  
      >>> # Add leaf to the false branch of node 2 that subtracts 1 from the result.
      >>> tm.add_leaf_node(0, 4, -1)
  
      >>> tm.set_default_prediction_value([0, 0])
  
      >>> # save the model to a .mlmodel file
      >>> model_path = './tree.mlmodel'
      >>> coremltools.models.utils.save_spec(tm.spec, model_path)
  
      >>> # load the .mlmodel
      >>> mlmodel = coremltools.models.MLModel(model_path)
  
      >>> # make predictions
      >>> test_input = {
      >>>     'a': np.array([0, 1, 2]).astype(np.float32),
      >>>     "b": 3.0,
      >>> }
      >>> predictions = mlmodel.predict(test_input)
class_docstr_tok: ["Tree","Ensemble","builder","class","to","construct","a","Tree","Ensemble","regression","model",".","The","TreeEnsembleRegressor","class","constructs","a","Tree","Ensemble","model","incrementally","using","methods","to","add","branch","and","leaf","nodes","specifying","the","behavior","of","the","model",".","Examples","--","--","--","--","In","the","following","example",",","the","code","saves","the","model","to","disk",",","which","is","a","recommended","practice","but","not","required",".","..","sourcecode",":",":","python",">",">",">","#","Required","inputs",">",">",">","import","coremltools",">",">",">","from","coremltools.models","import","datatypes",">",">",">","from","coremltools.models.tree_ensemble","import","TreeEnsembleRegressor",">",">",">","import","numpy","as","np",">",">",">","#","Define","input","features",">",">",">","input_features","=","[","(","``","a","''",",","datatypes.Array","(","3",")",")",",","(","``","b","''",",","(","datatypes.Double","(",")",")",")","]",">",">",">","#","Define","output_features",">",">",">","output_features","=","[","(","``","predicted_values","''",",","datatypes.Double","(",")",")","]",">",">",">","tm","=","TreeEnsembleRegressor","(","features","=","input_features",",","target","=","output_features",")",">",">",">","#","Split","on","a","[","2","]","<","=","3",">",">",">","tm.add_branch_node","(","0",",","0",",","2",",","3",",","``","BranchOnValueLessThanEqual","''",",","1",",","2",")",">",">",">","#","Add","leaf","to","the","true","branch","of","node","0","that","subtracts","1",".",">",">",">","tm.add_leaf_node","(","0",",","1",",","-1",")",">",">",">","#","Add","split","on","b","==","0","to","the","false","branch","of","node","0",",","which","is","index","3",">",">",">","tm.add_branch_node","(","0",",","2",",","3",",","0",",","``","BranchOnValueEqual","''",",","3",",","4",")",">",">",">","#","Add","leaf","to","the","true","branch","of","node","2","that","adds","1","to","the","result",".",">",">",">","tm.add_leaf_node","(","0",",","3",",","1",")",">",">",">","#","Add","leaf","to","the","false","branch","of","node","2","that","subtracts","1","from","the","result",".",">",">",">","tm.add_leaf_node","(","0",",","4",",","-1",")",">",">",">","tm.set_default_prediction_value","(","[","0",",","0","]",")",">",">",">","#","save","the","model","to","a",".mlmodel","file",">",">",">","model_path","=","'.\/tree.mlmodel'",">",">",">","coremltools.models.utils.save_spec","(","tm.spec",",","model_path",")",">",">",">","#","load","the",".mlmodel",">",">",">","mlmodel","=","coremltools.models.MLModel","(","model_path",")",">",">",">","#","make","predictions",">",">",">","test_input","=","{",">",">",">","'","a","'",":","np.array","(","[","0",",","1",",","2","]",")",".astype","(","np.float32",")",",",">",">",">","``","b","''",":","3.0",",",">",">",">","}",">",">",">","predictions","=","mlmodel.predict","(","test_input",")"]
docstr: Create a Tree Ensemble regression model that takes one or more input
  features and maps them to an output feature.
  
  Parameters
  ----------
  
  features: [list of features]
      Name(s) of the input features, given as a list of ``('name', datatype)``
      tuples.  The features are one of ``models.datatypes.Int64``,
      ``datatypes.Double``, or ``models.datatypes.Array``.
      Feature indices in the nodes are counted sequentially from 0 through
      the features.
  
  target:  (default = None)
     Name of the target feature predicted.
docstr_tok: ["Create","a","Tree","Ensemble","regression","model","that","takes","one","or","more","input","features","and","maps","them","to","an","output","feature",".","Parameters","--","--","--","--","--","features",":","[","list","of","features","]","Name","(","s",")","of","the","input","features",",","given","as","a","list","of","``","(","'name","'",",","datatype",")","``","tuples",".","The","features","are","one","of","``","models.datatypes.Int64","``",",","``","datatypes.Double","``",",","or","``","models.datatypes.Array","``",".","Feature","indices","in","the","nodes","are","counted","sequentially","from","0","through","the","features",".","target",":","(","default","=","None",")","Name","of","the","target","feature","predicted","."]
code: def __init__(self, features, target):
      """
      Create a Tree Ensemble regression model that takes one or more input
      features and maps them to an output feature.
  
      Parameters
      ----------
  
      features: [list of features]
          Name(s) of the input features, given as a list of ``('name', datatype)``
          tuples.  The features are one of ``models.datatypes.Int64``,
          ``datatypes.Double``, or ``models.datatypes.Array``.
          Feature indices in the nodes are counted sequentially from 0 through
          the features.
  
      target:  (default = None)
         Name of the target feature predicted.
      """
      super().__init__()
      spec = self.spec
      spec = set_regressor_interface_params(spec, features, target)
      self.tree_spec = spec.treeEnsembleRegressor
      self.tree_parameters = self.tree_spec.treeEnsemble
  
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 1 to create a new TreeEnsembleRegressor object from inherited base classes: TreeEnsembleBase with example: obj = TreeEnsembleRegressor(features, target)