def get_average_depth(self, settings, data):
        self.depth_nodes = {self.root: 0}
        tmp_node_list = [self.root]
        n_total = 0.
        average_depth = 0.
        self.node_size_by_depth = defaultdict(list)
        leaf_node_sizes = []
        while True:
            try:
                node_id = tmp_node_list.pop(0)
            except IndexError:
                break
            if node_id.is_leaf:
                if settings.optype == 'class':
                    n_points_node = np.sum(self.counts[node_id])
                else:
                    n_points_node = self.n_points[node_id]
                n_total += n_points_node
                average_depth += n_points_node * self.depth_nodes[node_id]
                self.node_size_by_depth[self.depth_nodes[node_id]].append(node_id.sum_range_d)
            if not node_id.is_leaf:
                self.depth_nodes[node_id.left] = self.depth_nodes[node_id] + 1
                self.depth_nodes[node_id.right] = self.depth_nodes[node_id] + 1
                tmp_node_list.extend([node_id.left, node_id.right])
            else:
                leaf_node_sizes.append(node_id.sum_range_d)
        assert data['n_train'] == int(n_total)
        average_depth /= n_total
        average_leaf_node_size = np.mean(leaf_node_sizes)
        average_node_size_by_depth = {}
        for k in self.node_size_by_depth:
            average_node_size_by_depth[k] = np.mean(self.node_size_by_depth[k])
        return (average_depth, average_leaf_node_size, average_node_size_by_depth)
compute average depth of tree (averaged over training data)
dataset/ETHPy150Open balajiln/mondrianforest/src/mondrianforest.py/MondrianTree.get_average_depth