简体   繁体   English

是否可以从通过 tidymodels 获得的随机森林中可视化一棵树?

[英]Is it possible to visualize an individual tree from a random forest obtained via tidymodels?

Good day,再会,

for presentation purposes I would like to plot a couple of decision trees from a random forest (with about 100 trees).出于演示目的,我想 plot 来自随机森林(大约 100 棵树)的几棵决策树。 I found a post from last year where its clear is not really possible or there is not an function using tidymodels.我发现了去年的一篇文章,其中明确是不可能的,或者没有使用 tidymodels 的 function。 R: Tidymodels: Is it possible to plot the trees for a random forest model in tidy models? R:Tidymodels:是否可以在整洁的模型中使用 plot 随机森林 model 的树木?

I´m wondering if somebody has found a way, I remember I could easily do this using the "Caret" package.我想知道是否有人找到了方法,我记得我可以使用“插入符号”package 轻松做到这一点。 but tidymodels makes everything so convenient I was hoping for someone with a solution.但是 tidymodels 让一切变得如此方便,我希望有人能提供解决方案。

Many thanks!非常感谢!

Summarizing what trees can be ploted with tidymodels based in comments comments and other Stackoverflow posts根据评论评论和其他 Stackoverflow 帖子总结可以使用 tidymodels 绘制的树

  • Decision trees.决策树。 There are some options but the function rpart.plot() seems to be the most popular.有一些选项,但 function rpart.plot()似乎是最受欢迎的。
  • Individual tree from a random forest.随机森林中的一棵树。 Doesn´t seem to be possible to plot one (yet) using the tidymodel environment. plot 似乎不可能使用 tidymodel 环境。 See this post: here看到这篇文章: 这里
  • XGBoost models: See Julia comment: XGBoost 型号:见 Julia 评论:

You should be able to use a function like xgb.plot.tree() with a trained tidymodels workflow or parsnip model by extracting out the underlying object created with the xgboost engine. You should be able to use a function like xgb.plot.tree() with a trained tidymodels workflow or parsnip model by extracting out the underlying object created with the xgboost engine. You can do this with extract_fit_engine()您可以使用extract_fit_engine()做到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM