def _get_node(self, data, target, level=1):
     print('level=', level)
     if level > self.split_count:
         node = TreeNode(level=level)
     else:
         node, meta = self._calc_split(data, target)
         node.level = level
         if not node.is_leaf():
             node.lo_branch = self._get_node(meta.get('lo_data'),
                                             target,
                                             level=++level)
             node.lo_branch.w = meta.get('lo_w')
             node.hi_branch = self._get_node(meta.get('hi_data'),
                                             target,
                                             level=++level)
             node.hi_branch.w = meta.get('hi_w')
     print('factor=', node.factor, 'value=', node.value)
     return node
Beispiel #2
0
 def test_node_empty(self):
     n = TreeNode()
     self.assertEqual(True, n.is_leaf())