[英]How can I get a single tree from an H2O Random Forest?
I'm doing a random forest with the next code:我正在用下一个代码做一个随机森林:
rf_md <- h2o.randomForest(training_frame = train_h,
nfolds = 5,
y = y,
ntrees = 500,
stopping_rounds = 10,
stopping_metric = "RMSE",
score_each_iteration = TRUE,
stopping_tolerance = 0.0001,
seed = 1234)
The output is an object with type: h2oregressionmodel
. output 是一个 object 类型: h2oregressionmodel
。 I want to get a single tree from the forest, so I found out that the function getTree()
works out very well with randomForest
objects.我想从森林中得到一棵树,所以我发现 function getTree()
非常适用于randomForest
对象。 How can I convert my actual output to a randomForest
object?如何将我的实际 output 转换为randomForest
object? or Can I get the same random forest with a different function which its output is a randomForest
object?或者我可以使用不同的 function 获得相同的随机森林,其中 output 是随机森林randomForest
?
Appreciate your help感谢你的帮助
H2O comes with a similar function, h2o.getModelTree
, which can be used for both GBM and Random Forest models (see the docs ); H2O 带有类似的 function、 h2o.getModelTree
,可用于 GBM 和随机森林模型(请参阅文档); in your case, for selecting, say, tree #3, it should be:在您的情况下,对于选择树#3,它应该是:
tree <- h2o.getModelTree(model=rf_md, tree_number=3)
In your example above, rf_md is the H2O-3 DRF (Distributed Random Forest) object.在上面的示例中,rf_md是H2O-3 DRF(分布式随机森林)object。 (Or, more specifically, a pointer to it. The real object lives in memory in the H2O-3 java process from the h2o.init()) (或者,更具体地说,是指向它的指针。真正的 object 位于 H2O-3 java 进程中的 H2O.init() 中的 memory
H2O-3 model objects are different from the native R package objects. H2O-3 model 对象不同于本机 R package 对象。 There is no way to convert an H2O-3 DRF model into an R randomForest model.无法将 H2O-3 DRF model 转换为 R randomForest model。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.