简体   繁体   English

在H2O XGBoost模型中可视化树木

[英]Visualize trees in H2O XGBoost model

I was looking at this answer to visualize the gradient boosting tree model in H2O, it says the method on GBM can be applied to XGBoost as well: 我在看这个答案以可视化H2O中的梯度增强树模型,它说GBM上的方法也可以应用于XGBoost:
Finding contribution by each feature into making particular prediction by h2o ensemble model 通过h2o集成模型找到每个特征的贡献以做出特定的预测

http://docs.h2o.ai/h2o/latest-stable/h2o-docs/productionizing.html http://docs.h2o.ai/h2o/latest-stable/h2o-docs/productionizing.html

But when I try to use the method it mentioned on H2O XGBoost MOJO, it fails. 但是,当我尝试使用H2O XGBoost MOJO上提到的方法时,它会失败。

I check the source code of hex.genmodel.tools.PrintMojo: https://github.com/h2oai/h2o-3/blob/master/h2o-genmodel/src/main/java/hex/genmodel/tools/PrintMojo.java 我检查了hex.genmodel.tools.PrintMojo的源代码: https : //github.com/h2oai/h2o-3/blob/master/h2o-genmodel/src/main/java/hex/genmodel/tools/PrintMojo。 java的

it seems like it can only work on randomforest and GBM models, but not XGBoost model. 似乎只能在randomforest和GBM模型上使用,而不能在XGBoost模型上使用。

Is there anyone who knows how to visualize trees in H2O XGBoost model? 有谁知道如何在H2O XGBoost模型中可视化树木? Thanks! 谢谢!

This is a feature H2O is currently adding, you can track its progress here: https://0xdata.atlassian.net/browse/PUBDEV-5743 . 这是H2O当前添加的功能,您可以在此处跟踪其进度: https : //0xdata.atlassian.net/browse/PUBDEV-5743

Note that in the ticket there is a suggestion in the comments on how to visualize the trees with native xgboost. 请注意,票证中的注释中有关于如何使用本机xgboost可视化树的建议。

I finally found the solution, that seem not documented for XGBoost, but it is indeed the same as for other trees-related algorithms. 我终于找到了解决方案,该解决方案似乎没有针对XGBoost进行记录,但确实与其他与树相关的算法相同。

Just run this command to generate the first 50 trees from your model: 只需运行以下命令即可从模型中生成前50棵树:

for tn in {1..50}
do
   java -cp h2o-3.24.0.1/h2o.jar hex.genmodel.tools.PrintMojo --tree $tn -i <your mojo model> -o XGBOOST_$tn.gv
   dot -Tpng  XGBOOST_$tn.gv -o xgboost_$tn.png
done

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

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