h2o grid search error

Hi RCommunity

 library("h2o")

h2o.init(max_mem_size = "16G")


train_h <- as.h2o(train_df)
test_h <- as.h2o(test_df)


forecast_h <- as.h2o(forecast_df)



x <- c("month", "lag12", "trend", "trend_sqr")
y <- "y"


rf_md <- h2o.randomForest(training_frame = train_h,
                          nfolds =5,
                          x = x,
                          y = y,
                          ntrees = 500,
                          stopping_rounds = 10,
                          stopping_metric = "RMSE",
                          score_each_iteration = TRUE,
                          stopping_tolerance = 0.0001,
                          seed = 1234)
                          

h2o.varimp_plot(rf_md)


rf_md@model$model_summary



library("plotly")

tree_score <- rf_md@model$scoring_history$training_rmse

plot_ly(x = seq_along(tree_score), y = tree_score, type = "scatter", mode ="line") %>%
          layout(title ="random forest model - the trained model score history",
                 yaxis = list(title = "RMSE"),
                 xaxis = list(title = "num of trees"))

test_h$pred_rf <- h2o.predict(rf_md, test_h)


test_1 <- as.data.frame(test_h)


mape_rf <- mean(abs(test_1$y - test_1$pred_rf) / test_1$y)
mape_rf




# ---------------------------------  GRID TUNING ------------------------------------------_#


hyper_params_rf <- list(mtries = c(2,3,4),
                        sample_rate = c(0.632,0.8,0.95),
                        col_sample_rate_per_tree = c(0.5,0.9,1.0),
                        max_depth = c(seq(1,30,3)),
                        min_rows = c(1,2,5,10))


search_criteria_rf <- list(strategy = "RandomDiscrete",
                           stopping_metric = "RMSE",
                           stopping_tolerance = 0.0001,
                           stopping_rounds = 10,
                           max_runtime_secs = 60*20
                           )

rf2 <- h2o.grid(algorithm = "randomForest",
                search_criteria = search_criteria_rf,
                hyper_params = hyper_params_rf,
                x = x,
                y = y,
                training_frame = train_h,
                ntrees = 5000,
                nfolds = 5,
                grid_id ="rf_grid",
                seed = 1234)

                                              


rf2_grid_search <- h2o.getGrid(grid_id =  "rf_grid",
                              sort_by = "rmse" ,
                              decreasing = FALSE)

print(rf2_grid_search)

rf_grid_search <- h2o.getGrid(rf2_grid_search@model_ids[[1]])

And get the following error:

rf_grid_search <- h2o.getGrid(rf2_grid_search@model_ids[[1]])

ERROR: Unexpected HTTP Status code: 404 Not Found (url = http://localhost:54321/99/Grids/rf_grid_model_18)

water.exceptions.H2OKeyWrongTypeArgumentException
[1] "water.exceptions.H2OKeyWrongTypeArgumentException: Expected a Grid for key argument: grid_id with value: rf_grid_model_18. Found a: DRFModel"
[2] " water.api.Handler.getFromDKV(Handler.java:105)"
[3] " water.api.GridsHandler.fetch(GridsHandler.java:41)"
[4] " sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
[5] " sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)"
[6] " sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
[7] " java.lang.reflect.Method.invoke(Method.java:498)"
[8] " water.api.Handler.handle(Handler.java:60)"
[9] " water.api.RequestServer.serve(RequestServer.java:470)"
[10] " water.api.RequestServer.doGeneric(RequestServer.java:301)"
[11] " water.api.RequestServer.doGet(RequestServer.java:225)"
[12] " javax.servlet.http.HttpServlet.service(HttpServlet.java:687)"
[13] " javax.servlet.http.HttpServlet.service(HttpServlet.java:790)"
[14] " org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)"
[15] " org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)"
[16] " org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)"
[17] " org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)"
[18] " org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)"
[19] " org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)"
[20] " org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)"
[21] " org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)"
[22] " org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)"
[23] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)"
[24] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)"
[25] " water.webserver.jetty9.Jetty9ServerAdapter$LoginHandler.handle(Jetty9ServerAdapter.java:130)"
[26] " org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)"
[27] " org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)"
[28] " org.eclipse.jetty.server.Server.handle(Server.java:531)"
[29] " org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)"
[30] " org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)"
[31] " org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)"
[32] " org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)"
[33] " org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)"
[34] " org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)"
[35] " org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)"
[36] " org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)"
[37] " org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)"
[38] " org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)"
[39] " org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)"
[40] " org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)"
[41] " java.lang.Thread.run(Thread.java:748)"

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page, :

ERROR MESSAGE:

Expected a Grid for key argument: grid_id with value: rf_grid_model_18. Found a: DRFModel

I am not sure what that even means, or how to solve it... any ideas?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.