(self)
Update the node color for classification trees
Update the node color for classification trees
Update the node color for classification trees
def toggle_node_color_cls(self):
        """Update the node color for classification trees"""
        colors = self.scene.colors
        for node in self.scene.nodes():
            distr = node.tree_adapter.get_distribution(node.node_inst)[0]
            total = sum(distr)
            if self.target_class_index:
                p = distr[self.target_class_index - 1] / total
                color = colors[self.target_class_index - 1].lighter(
                    200 - 100 * p)
            else:
                modus = np.argmax(distr)
                p = distr[modus] / (total or 1)
                color = colors.value_to_qcolor(int(modus))
                color = color.lighter(300 - 200 * p)
            node.backgroundBrush = QBrush(color)
        self.scene.update()
def toggle_node_color_cls ( self ) : colors = self . scene . colors for node in self . scene . nodes ( ) : distr = node . tree_adapter . get_distribution ( node . node_inst ) [ 0 ] total = sum ( distr ) if self . target_class_index : p = distr [ self . target_class_index - 1 ] / total color = colors [ self . target_class_index - 1 ] . lighter ( 200 - 100 * p ) else : modus = np . argmax ( distr ) p = distr [ modus ] / ( total or 1 ) color = colors . value_to_qcolor ( int ( modus ) ) color = color . lighter ( 300 - 200 * p ) node . backgroundBrush = QBrush ( color ) self . scene . update ( )