简体   繁体   English

我可以将使用 h2o 训练的模型导出为 Java 代码吗?

[英]Could I export model trained with h2o to Java code?

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

Yes.是的。 This is exactly what the POJO is for.这正是POJO的用途。 In your R script, if m is your model, then you can get the POJO with:在您的 R 脚本中,如果m是您的模型,那么您可以通过以下方式获取 POJO:

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

This will choose the filename, and create a java file in the directory you give.这将选择文件名,并在您提供的目录中创建一个 java 文件。 By default it will also download the jar file you need.默认情况下,它还会下载您需要的 jar 文件。

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.如果不希望保存到本地文件系统,请不要提供路径(即只执行h2o.download_pojo(m) ),它会将 java 类输出到您的 R 会话,您可以在其中捕获输出,然后执行某些操作接着就,随即。

Also take a look at h2o.download_mojo() , which gives a different format.另请查看h2o.download_mojo() ,它提供了不同的格式。 It is for tree models, which can get very big (in fact it only supports random forest, GBM and GLM currently).它用于树模型,它可以变得非常大(实际上它目前只支持随机森林、GBM 和 GLM)。

More info on both POJO and MOJO here: http://docs.h2o.ai/h2o/latest-stable/h2o-docs/pojo-quick-start.html有关 POJO 和 MOJO 的更多信息,请访问: http : //docs.h2o.ai/h2o/latest-stable/h2o-docs/pojo-quick-start.html

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

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