Esempio n. 1
0
 def print_tree_rec(self, node_ind):
     if SC.is_leaf(node_ind, self.left_child):
         return SP.str_(self.mean[node_ind])
     else:
         left_child = self.left_child[node_ind]
         right_child = self.right_child[node_ind]
         return '(' + self.print_tree_rec(left_child) + ','\
             + self.print_tree_rec(right_child) + ')'
Esempio n. 2
0
 def print_tree_rec(self, node_ind):
     if SC.is_leaf(node_ind, self.left_child):
         return SP.str_(self.mean[node_ind])
     else:
         left_child = self.left_child[node_ind]
         right_child = self.right_child[node_ind]
         return '(' + self.print_tree_rec(left_child) + ','\
             + self.print_tree_rec(right_child) + ')'
Esempio n. 3
0
 def predict_rec(self, node_ind, x, depth):
     if self.get_depth(self.nodes[node_ind]) == depth or SC.is_leaf(node_ind,
                       self.left_child):
         return self.mean[node_ind]
     else:
         if x[self.best_predictor[node_ind]] < self.s[node_ind]:
             # Go to left child node
             return self.predict_rec(self.left_child[node_ind], x, depth)
         else:
             # Else go to right child node
             return self.predict_rec(self.right_child[node_ind], x, depth)
Esempio n. 4
0
 def predict_rec(self, node_ind, x, depth):
     if self.get_depth(self.nodes[node_ind]) == depth or SC.is_leaf(
             node_ind, self.left_child):
         return self.mean[node_ind]
     else:
         if x[self.best_predictor[node_ind]] < self.s[node_ind]:
             # Go to left child node
             return self.predict_rec(self.left_child[node_ind], x, depth)
         else:
             # Else go to right child node
             return self.predict_rec(self.right_child[node_ind], x, depth)