是否有任何“简单”方法从H2O随机森林模型中绘制树木。我也有兴趣提取结果规则?
答案 0 :(得分:1)
是
从此文档:
以下代码段显示了如何从R下载MOJO并在命令行上运行PrintMojo工具来生成.png文件:
jwt
答案 1 :(得分:0)
可以在这里找到示例python实现: https://gist.github.com/ahmedengu/e2cbc2d937e48de3f43b3c903d656143 https://dzone.com/articles/visualizing-h2o-gbm-and-random-forest-mojo-models
# save model to mojo and view it as an image
# R code sample and more information available here: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/productionizing.html#viewing-a-mojo-model
# another python example could be found here: https://dzone.com/articles/visualizing-h2o-gbm-and-random-forest-mojo-models
model = aml.leader # the model that we want to plot it can be any h2o model as long as it's not a StackedEnsemble model
model_path = model.download_mojo(get_genmodel_jar=True)
# download h2o jar
!wget -c http://h2o-release.s3.amazonaws.com/h2o/rel-xia/2/h2o-3.22.0.2.zip
!unzip -n h2o-3.22.0.2.zip
!java -cp h2o-3.22.0.2/h2o.jar hex.genmodel.tools.PrintMojo --tree 0 -i $model_path -o model.gv -f 20 -d 3
!dot -Tpng model.gv -o model.png
from IPython.display import display
from PIL import Image
# showing the image in notebook
display(Image.open('model.png'))