在sci-kit learn中,可以访问整个树结构,即树的每个节点。这允许探索在树的每个分裂中使用的属性以及用于测试的哪些值。
The binary tree structure has 5 nodes and has the following tree structure:
node=0 test node: go to node 1 if X[:, 3] <= 0.800000011920929 else to node 2.
node=1 leaf node.
node=2 test node: go to node 3 if X[:, 2] <= 4.950000047683716 else to node 4.
node=3 leaf node.
node=4 leaf node.
Rules used to predict sample 0:
decision id node 0 : (X_test[0, 3] (= 2.4) > 0.800000011920929)
decision id node 2 : (X_test[0, 2] (= 5.1) > 4.950000047683716)
对于随机森林,您可以通过循环遍历所有决策树来获取相同的信息。
for tree in model.estimators_:
# extract info from tree
LightGBM模型是否可以提取相同的信息?也就是说,您能否访问:a)每个树和b)每个树节点?