0
のchildren_left属性を解釈する方法sklearn DecisionTreeClassifierの 'tree_'メソッドを使用して最も深いノードの規則を抽出しようとしています。私は、 'children_left'と 'children_right'の配列がモデルから何を意味しているのかを理解するのに苦労しています。誰でも説明できる? Sklearnの例ではsklearn決定木tree_
estimator = DecisionTreeClassifier(max_depth=4, random_state=0)
estimator.fit(X_train, y_train)
estimator.tree_.children_left
[6] array([ 1, 2, 3, 4, 5, -1, -1, 8, -1, -1, 11, 12, -1, -1, 15, -1, -1,
18, 19, 20, -1, -1, 23, -1, -1, 26, 27, -1, -1, 30, -1, -1, 33, 34,
35, 36, -1, -1, 39, -1, -1, 42, 43, -1, -1, 46, -1, -1, 49, 50, 51,
-1, -1, 54, -1, -1, 57, 58, -1, -1, 61, -1, -1])
tree_model.tree_.children_right
[7] array([32, 17, 10, 7, 6, -1, -1, 9, -1, -1, 14, 13, -1, -1, 16, -1, -1,
25, 22, 21, -1, -1, 24, -1, -1, 29, 28, -1, -1, 31, -1, -1, 48, 41,
38, 37, -1, -1, 40, -1, -1, 45, 44, -1, -1, 47, -1, -1, 56, 53, 52,
-1, -1, 55, -1, -1, 60, 59, -1, -1, 62, -1, -1])
、http://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html、それは言う:
`# The decision estimator has an attribute called tree_ which stores the entire
# tree structure and allows access to low level attributes. The binary tree
# 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. NOTE:
# Some of the arrays only apply to either leaves or split nodes, resp.`
しかし、それはポストからchildren_left配列