class_docstr: Tree Ensemble builder class to construct a Tree Ensemble classification model.
  
  The TreeEnsembleClassifier 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
  
      >>> input_features = [("a", datatypes.Array(3)), ("b", datatypes.Double())]
  
      >>> tm = TreeEnsembleClassifier(features = input_features, class_labels = [0, 1],
                                      output_features = "predicted_class")
  
      >>> # 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.
      >>> 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)
  
      >>> # Put in a softmax transform to translate these into probabilities.
      >>> tm.set_post_evaluation_transform("Classification_SoftMax")
  
      >>> 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","classification","model",".","The","TreeEnsembleClassifier","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",">",">",">","input_features","=","[","(","``","a","''",",","datatypes.Array","(","3",")",")",",","(","``","b","''",",","datatypes.Double","(",")",")","]",">",">",">","tm","=","TreeEnsembleClassifier","(","features","=","input_features",",","class_labels","=","[","0",",","1","]",",","output_features","=","``","predicted_class","''",")",">",">",">","#","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",".",">",">",">","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",")",">",">",">","#","Put","in","a","softmax","transform","to","translate","these","into","probabilities",".",">",">",">","tm.set_post_evaluation_transform","(","``","Classification_SoftMax","''",")",">",">",">","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 classifier model.
  
  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.
  
  class_labels: [list]
      A list of string or integer class labels to use in making predictions.
      The length of this must match the dimension of the tree model.
  
  output_features: [list]
      A string or a list of two strings specifying the names of the two
      output features, the first being a class label corresponding
      to the class with the highest predicted score, and the second being
      a dictionary mapping each class to its score. If ``output_features``
      is a string, it specifies the predicted class label and the class
      scores is set to the default value of ``"classProbability"``.
docstr_tok: ["Create","a","tree","ensemble","classifier","model",".","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",".","class_labels",":","[","list","]","A","list","of","string","or","integer","class","labels","to","use","in","making","predictions",".","The","length","of","this","must","match","the","dimension","of","the","tree","model",".","output_features",":","[","list","]","A","string","or","a","list","of","two","strings","specifying","the","names","of","the","two","output","features",",","the","first","being","a","class","label","corresponding","to","the","class","with","the","highest","predicted","score",",","and","the","second","being","a","dictionary","mapping","each","class","to","its","score",".","If","``","output_features","``","is","a","string",",","it","specifies","the","predicted","class","label","and","the","class","scores","is","set","to","the","default","value","of","``","``","classProbability","''","``","."]
code: def __init__(self, features, class_labels, output_features):
      """
      Create a tree ensemble classifier model.
  
      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.
  
      class_labels: [list]
          A list of string or integer class labels to use in making predictions.
          The length of this must match the dimension of the tree model.
  
      output_features: [list]
          A string or a list of two strings specifying the names of the two
          output features, the first being a class label corresponding
          to the class with the highest predicted score, and the second being
          a dictionary mapping each class to its score. If ``output_features``
          is a string, it specifies the predicted class label and the class
          scores is set to the default value of ``"classProbability"``.
      """
      super().__init__()
      spec = self.spec
      spec = set_classifier_interface_params(
          spec,
          features,
          class_labels,
          "treeEnsembleClassifier",
          output_features,
      )
      self.tree_spec = spec.treeEnsembleClassifier
      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 TreeEnsembleClassifier object from inherited base classes: TreeEnsembleBase with example: obj = TreeEnsembleClassifier(features, class_labels, output_features)