简体   繁体   中英

Could I export model trained with h2o to Java code?

R包级别使用h2o时,我可以将用h2o训练的模型导出到 Java 代码吗?

Yes. This is exactly what the POJO is for. In your R script, if m is your model, then you can get the POJO with:

h2o.download_pojo(m, "/path/to/save/in/");

This will choose the filename, and create a java file in the directory you give. By default it will also download the jar file you need.

If saving to the local file system is not desirable, don't give a path (ie do just h2o.download_pojo(m) ) and it will output the java class to your R session, where you could capture the output, and do something with that.

Also take a look at h2o.download_mojo() , which gives a different format. It is for tree models, which can get very big (in fact it only supports random forest, GBM and GLM currently).

More info on both POJO and MOJO here: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/pojo-quick-start.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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