コード例 #1
0
        def filter_instance_to_leaves(self, X, y, weight, parent, parent_branch,
                                      update_splitter_counts=False, found_nodes=None):
            if found_nodes is None:
                found_nodes = []
            if update_splitter_counts:

                try:

                    self._observed_class_distribution[0] += weight
                    self._observed_class_distribution[1] += y * weight
                    self._observed_class_distribution[2] += y * y * weight

                except KeyError:

                    self._observed_class_distribution[0] = weight
                    self._observed_class_distribution[1] = y * weight
                    self._observed_class_distribution[2] = y * y * weight

            child_index = self.instance_child_index(X)
            if child_index >= 0:
                child = self.get_child(child_index)
                if child is not None:
                    child.filter_instance_to_leaves(X, y, weight, parent, parent_branch,
                                                    update_splitter_counts, found_nodes)
                else:
                    found_nodes.append(HoeffdingTree.FoundNode(None, self, child_index))
            if self._alternate_tree is not None:
                self._alternate_tree.filter_instance_to_leaves(X, y, weight, self, -999,
                                                               update_splitter_counts, found_nodes)
コード例 #2
0
 def filter_instance_to_leaves(self,
                               X,
                               y,
                               weight,
                               parent,
                               parent_branch,
                               update_splitter_counts,
                               found_nodes=None):
     if found_nodes is None:
         found_nodes = []
     found_nodes.append(
         HoeffdingTree.FoundNode(self, parent, parent_branch))