class_docstr: An encapsulation of the structure of a single decision tree
  Contains no logic, but keeps track of 4 different kinds of nodes within the tree:
    - leaf nodes
    - decision nodes
    - splittable leaf nodes
    - prunable decision nodes
  
  Parameters
  ----------
  nodes: List[Node]
      All nodes contained in the tree, i.e. decision and leaf nodes
class_docstr_tok: ["An","encapsulation","of","the","structure","of","a","single","decision","tree","Contains","no","logic",",","but","keeps","track","of","4","different","kinds","of","nodes","within","the","tree",":","-","leaf","nodes","-","decision","nodes","-","splittable","leaf","nodes","-","prunable","decision","nodes","Parameters","--","--","--","--","--","nodes",":","List","[","Node","]","All","nodes","contained","in","the","tree",",","i.e",".","decision","and","leaf","nodes"]
docstr: Generate a set of predictions with the same dimensionality as the target array
  Note that the prediction is from one tree, so represents only (1 / number_of_trees) of the target
docstr_tok: ["Generate","a","set","of","predictions","with","the","same","dimensionality","as","the","target","array","Note","that","the","prediction","is","from","one","tree",",","so","represents","only","(","1","\/","number_of_trees",")","of","the","target"]
code: def predict(self, X: np.ndarray = None) -> np.ndarray:
      """
      Generate a set of predictions with the same dimensionality as the target array
      Note that the prediction is from one tree, so represents only (1 / number_of_trees) of the target
      """
      if X is not None:
          return self._out_of_sample_predict(X)
  
      if self.cache_up_to_date:
          return self._prediction
      for leaf in self.leaf_nodes:
          if self._prediction is None:
              self._prediction = np.zeros(self.nodes[0].data.X.n_obsv)
          self._prediction[leaf.split.condition()] = leaf.predict()
      self.cache_up_to_date = True
      return self._prediction
  
file_path: imodels/imodels/experimental/bartpy/tree.py
imports: from typing import List
  import numpy
  from .mutation import TreeMutation
  from .node import TreeNode, LeafNode, DecisionNode, deep_copy_node
label_desc: Use image node_id 8 for calling the Tree obj's underlying member method code with example usage: obj.predict(X) and returns: self, self, self