我已经阅读了H2O文档有一段时间了,但是我还没有找到一个清楚的例子来说明如何使用Python API来加载model
训练和保存。我在学下一个例子。在
import h2o
from h2o.estimators.naive_bayes import H2ONaiveBayesEstimator
model = H2ONaiveBayesEstimator()
h2o_df = h2o.import_file("http://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip")
model.train(y = "IsDepDelayed", x = ["Year", "Origin"],
training_frame = h2o_df,
family = "binomial",
lambda_search = True,
max_active_predictors = 10)
h2o.save_model(model, path=models)
但是如果您检查官方的documentation,它说明您必须以POJO
的形式从流UI下载模型。这是唯一的办法吗?或者,我可以通过python获得相同的结果吗?下面我展示了doc的示例,仅供参考。我需要一些指导。在
save_model会将二进制模型保存到提供的文件系统中,但是,看看上面的Java应用程序,您似乎希望将model用于基于Java的评分应用程序中。在
因此,您应该使用h2o.download_pojo API将模型与genmodel jar文件一起保存到本地文件系统。API记录如下:
一旦下载了POJO,就可以使用上面的示例应用程序来执行评分,并确保POJO类名和“modelClassName”与model type相同。在
相关问题 更多 >
编程相关推荐