Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when computing Friedman H Statistic #15876

Closed
RoelVerbelen opened this issue Oct 26, 2023 · 1 comment
Closed

Errors when computing Friedman H Statistic #15876

RoelVerbelen opened this issue Oct 26, 2023 · 1 comment
Assignees
Labels

Comments

@RoelVerbelen
Copy link

H2O version 3.42.0.2, Windows OS, R version 4.3.0

h2o.h() does not seem to work under all circumstances.

Reprex:

library(h2o)
h2o.init()

# Import the prostate dataset into H2O:
prostate <- h2o.importFile("http://s3.amazonaws.com/h2o-public-test-data/smalldata/prostate/prostate.csv")

# Set the predictors and response; set the factors:
prostate$CAPSULE <- as.factor(prostate$CAPSULE)
prostate$RACE <- as.factor(prostate$RACE)
prostate$DPROS <- as.factor(prostate$DPROS)
prostate$DCAPS <- as.factor(prostate$DCAPS)
prostate$GLEASON <- as.factor(prostate$GLEASON)
predictors <- c("AGE", "RACE", "DPROS", "DCAPS", "PSA", "VOL", "GLEASON")
response <- "CAPSULE"

# Build and train the model:
pros_gbm <- h2o.gbm(x = predictors,
                    y = response,
                    nfolds = 5,
                    seed = 1111,
                    keep_cross_validation_predictions = TRUE,
                    training_frame = prostate)
# Works
h2o.h(pros_gbm, prostate, c("AGE", "PSA"))
#> [1] 0.1965383

# Does not work
h2o.h(pros_gbm, prostate, c("GLEASON", "PSA"))
#> 
#> ERROR: Unexpected HTTP Status code: 400 Bad Request (url = http://localhost:54321/3/FriedmansPopescusH)
#> 
#> java.lang.IllegalArgumentException
#>  [1] "java.lang.IllegalArgumentException: Vec C2 is not compatible with the rest of the frame"                     
#>  [2] "    water.fvec.Frame.checkCompatibility(Frame.java:265)"                                                     
#>  [3] "    water.fvec.Frame.<init>(Frame.java:172)"                                                                 
#>  [4] "    water.fvec.Frame.<init>(Frame.java:142)"                                                                 
#>  [5] "    water.fvec.Frame.<init>(Frame.java:137)"                                                                 
#>  [6] "    water.MRTask.doAll(MRTask.java:412)"                                                                     
#>  [7] "    water.MRTask.doAll(MRTask.java:397)"                                                                     
#>  [8] "    hex.tree.FriedmanPopescusH.computeFValues(FriedmanPopescusH.java:214)"                                   
#>  [9] "    hex.tree.FriedmanPopescusH.h(FriedmanPopescusH.java:48)"                                                 
#> [10] "    hex.tree.gbm.GBMModel.getFriedmanPopescusH(GBMModel.java:327)"                                           
#> [11] "    water.api.ModelsHandler.makeFriedmansPopescusH(ModelsHandler.java:203)"                                  
#> [12] "    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"                                             
#> [13] "    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)"                           
#> [14] "    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"                   
#> [15] "    java.lang.reflect.Method.invoke(Method.java:498)"                                                        
#> [16] "    water.api.Handler.handle(Handler.java:60)"                                                               
#> [17] "    water.api.RequestServer.serve(RequestServer.java:472)"                                                   
#> [18] "    water.api.RequestServer.doGeneric(RequestServer.java:303)"                                               
#> [19] "    water.api.RequestServer.doPost(RequestServer.java:227)"                                                  
#> [20] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:707)"                                            
#> [21] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:790)"                                            
#> [22] "    org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)"                                  
#> [23] "    org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)"                              
#> [24] "    org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)"                       
#> [25] "    org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)"                      
#> [26] "    org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)"                        
#> [27] "    org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)"                               
#> [28] "    org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)"                        
#> [29] "    org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)"                       
#> [30] "    org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)"                           
#> [31] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)"                   
#> [32] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)"                         
#> [33] "    water.webserver.jetty9.Jetty9ServerAdapter$LoginHandler.handle(Jetty9ServerAdapter.java:130)"            
#> [34] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)"                   
#> [35] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)"                         
#> [36] "    org.eclipse.jetty.server.Server.handle(Server.java:531)"                                                 
#> [37] "    org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)"                                       
#> [38] "    org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)"                             
#> [39] "    org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)"             
#> [40] "    org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)"                                       
#> [41] "    org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)"                                    
#> [42] "    org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)"                  
#> [43] "    org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)"                
#> [44] "    org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)"               
#> [45] "    org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)"                      
#> [46] "    org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)"
#> [47] "    org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)"                        
#> [48] "    org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)"                         
#> [49] "    java.lang.Thread.run(Thread.java:750)"
#> Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = urlSuffix, : 
#> 
#> ERROR MESSAGE:
#> 
#> Vec C2 is not compatible with the rest of the frame

# Other examples that don't work
# h2o.h(pros_gbm, prostate, c("VOL", "GLEASON"))
# h2o.h(pros_gbm, prostate, c("VOL", "DPROS"))
# h2o.h(pros_gbm, prostate, c("AGE", "DPROS"))

Created on 2023-10-26 with reprex v2.0.2

@maurever
Copy link
Contributor

Hi @RoelVerbelen, our current H calculation does not support categorical features. We are working on adding documentation about it (#15879). In version 3.44.0.1, we added an error message that is more informative. The categorical features support is on the list to do.

See: #15880

@maurever maurever self-assigned this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants