有没有办法使用 LightGBM 分类器以列表形式获取树数据

发布于 2025-01-11 05:54:29 字数 155 浏览 2 评论 0 原文

在随机森林类型模型中,通常有一个像“估计器”这样的属性,它将所有树分割作为列表的列表返回。 我似乎找不到与 lightgbm 类似的东西。我能想到的最接近的是lgb.plot_tree,它提供了单个树的良好可视化效果。但我想在变量中使用可视化中显示的数据。

我怎样才能得到这些数据?

In random forest type models, there is usually an attribute like "estimators" which returns all the tree split as a list of lists.
I can't seem find something similar with lightgbm. The closest I can come is lgb.plot_tree which gives a nice visualization of a single tree. But I would like to use the data shown in the visualization in variables.

How can I get at this data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗心遗梦遗幸福 2025-01-18 05:54:29

LightGBM 中没有完全相同的东西。但是您可以使用 dump_modeltrees_to_dataframe booster_ scikit-learn 估计器的属性, IE

clf = lgb.LGBMClassifier().fit(X, y)
clf.booster_.dump_model()
clf.booster_.trees_to_dataframe()

There's not something exactly the same in LightGBM. But you could use the dump_model or trees_to_dataframe methods of the booster_ attribute of the scikit-learn estimator, i.e.

clf = lgb.LGBMClassifier().fit(X, y)
clf.booster_.dump_model()
clf.booster_.trees_to_dataframe()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文