sklearn中DecisionTreeClassifier的遍历方法

2024-10-02 08:25:29 发布

您现在位置:Python中文网/ 问答频道 /正文

此类用于构建决策树。树结构中的许多值(包括tree_u0.value和tree_0.value)都保存为数组,而没有太多指示每个值所指的节点。我的推论告诉我,他们正在进行一次前序遍历,但我没有确凿的证据证明每个数组都是这样构造的。有人知道在哪里可以找到这些信息吗


Tags: 证明信息决策树tree证据节点value数组
1条回答
网友
1楼 · 发布于 2024-10-02 08:25:29

tree.pyx

    def class Tree:
    """Array-based representation of a binary decision tree.
    The binary tree is represented as a number of parallel arrays. The i-th
    element of each array holds information about the node `i`. Node 0 is the
    tree's root. You can find a detailed description of all arrays in
    `_tree.pxd`. NOTE: Some of the arrays only apply to either leaves or split
    nodes, resp. In this case the values of nodes of the other type are
    arbitrary!

所以节点[0]是指根。要添加节点,它在叶子上使用一个splitter类,该类可以基于杂质改善程度更高的叶子分割节点,或者使用深度优先分割。我没有研究将节点添加到并行中的顺序,但我猜测它们是按照创建它们的顺序添加的,如果树是按顺序排列的,那么这将“类似于”预顺序横向

相关问题 更多 >

    热门问题