def get_leafs_num(tree):
    """
    获得树的叶结点个数，以在绘制树是分配空间
    :param tree: 决策树
    :return: 树的叶结点个数
    """
    if isinstance(tree, dict):
        leafs_num = 0
        root = list(tree.values())[0]
        for node in root.values():
            leafs_num += get_leafs_num(node)
        return leafs_num
    else:
        return 1