gpt4 book ai didi

nodes - 从 LightGBM 模型访问树和节点

转载 作者:行者123 更新时间:2023-12-03 19:32:14 25 4
gpt4 key购买 nike

在 sci-kit learn 中,可以访问整个树结构,即树的每个节点。这允许探索在树的每个 split 中使用的属性以及用于测试的值

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) 树的每个节点吗?

最佳答案

是的,这是可能的

model._Booster.dump_model()["tree_info"]

例如用于 lightgbm.plot_tree() .我必须承认,我自己没有使用过它,也不知道有关返回结构的详细信息。

关于nodes - 从 LightGBM 模型访问树和节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53280845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com