treemethods.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ML-lib 作者: christopherjenness 项目源码 文件源码
def compute_class_averages(self):
        """
        Computes the class average of each node in the tree.
        Class average is the mode of training data that partitions to the node.
        """
        for i in range(2, self.nodes + 1):
            parent = self.graph.predecessors(i)[0]
            if self.graph.node[parent]['cutoff'] is None:
                self.graph.node[i]['classval'] = self.graph.node[parent]['classval']
            else:
                node_indices = self.partition_data(i)
                classval = mode(self.y[node_indices]).mode[0]
                self.graph.node[i]['classval'] = classval
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号