How to save / load a trained model in H2o?

The user tutorial says

Navigate to Data > View All Choose to filter by the model key Hit Save Model Input for path: /data/h2o-training/... Hit Submit 

The problem is that I do not have this menu (H2o, 3.0.0.26, web interface)

+7
h2o
source share
5 answers

Unfortunately, I am not familiar with the web interface, but I can offer a workaround with H2O in R. Functions

 h2o.saveModel(object, dir = "", name = "", filename = "", force = FALSE) 

and

 h2o.loadModel(path, conn = h2o.getConnection()) 

Suggest what you need. I will try to take a look at the H2O stream.

Update

I cannot find the option to explicitly save the model. Instead, you can save the Stream. You can upload / import your file, build a model, and then save / load the status :-)

+5
source share

When viewing a model in H2O Flow, you will see the Export button as an action that can be applied to the model

From there, you will be prompted to specify the path in the Export Model dialog box. Specify the path and click the "Export" button. This will save you from the model to disk.

I mean version H2O 3.2.0.3

+2
source share

A working example that I used recently when building a deep learning model in version 2.8.6 in h2o. The model was saved in hdf. For the latest version, you probably have to remove the class = T switch and replace the data with training_frame

 library(h2o) h = h2o.init(ip="xx.xxx.xxx.xxx", port=54321, startH2O = F) cTrain.h2o <- as.h2o(h,cTrain,key="c1") cTest.h2o <- as.h2o(h,cTest,key="c2") nh2oD<-h2o.deeplearning(x =c(1:12),y="tgt",data=cTrain.h2o,classification=F,activation="Tanh", rate=0.001,rho=0.99,momentum_start=0.5,momentum_stable=0.99,input_dropout_ratio=0.2, hidden=c(12,25,11,11),hidden_dropout_ratios=c(0.4,0.4,0.4,0.4), epochs=150,variable_importances=T,seed=1234,reproducible = T,l1=1e-5, key="dn") hdfsdir<-"hdfs://xxxxxxxxxx/user/xxxxxx/xxxxx/models" h2o.saveModel(nh2oD,hdfsdir,name="DLModel1",save_cv=T,force=T) test=h2o.loadModel(h,path=paste0(hdfsdir,"/","DLModel1")) 
+1
source share

This should be what you need:

 library(h2o) h2o.init() path = system.file("extdata", "prostate.csv", package = "h2o") h2o_df = h2o.importFile(path) h2o_df$CAPSULE = as.factor(h2o_df$CAPSULE) model = h2o.glm(y = "CAPSULE", x = c("AGE", "RACE", "PSA", "GLEASON"), training_frame = h2o_df, family = "binomial") h2o.download_pojo(model) 

http://h2o-release.s3.amazonaws.com/h2o/rel-slater/5/docs-website/h2o-docs/index.html#POJO%20Quick%20Start

+1
source share

How to save models in H2O stream:

How to save a trained model in h2o-py:

 # say "rf" is your H2ORandomForestEstimator object. To export it >>> path = h2o.save_model(rf, force=True) # save_model() returns the path >>> path u'/home/user/rf' #to import it back again(as a new object) >>> rafo = h2o.load_model(path) >>> rafo # prints model details Model Details ============= H2ORandomForestEstimator : Distributed Random Forest Model Key: drf1 Model Summary: ######Prints model details................... 
+1
source share

All Articles