此类用于构建决策树。树结构中的许多值(包括tree_.value和tree_.impurity)都保存为数组,而没有太多指示每个值所指向的节点。我的推论告诉我,它们正在进行预遍历,但是我没有确凿的证据证明这是构造每个数组的方式。有人知道在哪里可以找到此信息吗?
来自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]指的是根。要添加节点,它在叶子上使用拆分器类,该类可以基于杂质改进程度更大的叶子来拆分节点,也可以采用深度优先拆分。我没有研究将节点添加到并行中的顺序,但是我猜测是按照创建它们的顺序添加它们,如果树按杂质顺序排序,这将类似于“预先横向”改进。