@@ -615,6 +615,10 @@ cdef class BestSplitter(Splitter):
615615 if self .honest:
616616 self .criterion_val.reset()
617617 self .criterion_val.update(best.pos_val)
618+ # Calculate a more accurate version of impurity improvement using the input baseline impurity
619+ # passed here by the TreeBuilder. The TreeBuilder uses the proxy_node_impurity() to calculate
620+ # this baseline if self.is_children_impurity_proxy(), else uses the call to children_impurity()
621+ # on the parent node, when that node was split.
618622 # if we need children impurities by the builder, then we populate these entries
619623 # otherwise, we leave them blank to avoid the extra computation.
620624 if not self .is_children_impurity_proxy():
@@ -626,10 +630,6 @@ cdef class BestSplitter(Splitter):
626630 best.impurity_left_val = best.impurity_left
627631 best.impurity_right_val = best.impurity_right
628632
629- # Calculate a more accurate version of impurity improvement using the input baseline impurity
630- # passed here by the TreeBuilder. The TreeBuilder uses the proxy_node_impurity() to calculate
631- # this baseline if self.is_children_impurity_proxy(), else uses the call to children_impurity()
632- # on the parent node, when that node was split.
633633 best.improvement = self .criterion.impurity_improvement(impurity,
634634 best.impurity_left, best.impurity_right)
635635
0 commit comments