Convert R dataframe into h2o object - error: Provided column type ordered is unknown

Convert R dataframe into h2o object - error: Provided column type ordered is unknown

我是运行R中的以下代码

library(h2o)
h2o.init()  

df <- as.h2o(diamonds)

并返回以下错误:

ERROR: Unexpected HTTP Status code: 412 Precondition Failed (url = http://localhost:54321/3/Parse)

water.exceptions.H2OIllegalArgumentException
 [1] "water.exceptions.H2OIllegalArgumentException: Provided column type ordered is unknown.  Cannot proceed with parse due to invalid argument."
 [2] "    water.parser.ParseSetup.strToColumnTypes(ParseSetup.java:240)"                                                                         
 [3] "    water.api.ParseHandler.parse(ParseHandler.java:21)"                                                                                    
 [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:462)"                                                                                 
[10] "    water.api.RequestServer.doGeneric(RequestServer.java:295)"                                                                             
[11] "    water.api.RequestServer.doPost(RequestServer.java:221)"                                                                                
[12] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:755)"                                                                          
[13] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:848)"                                                                          
[14] "    org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)"                                                                
[15] "    org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)"                                                            
[16] "    org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)"                                                    
[17] "    org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:427)"                                                             
[18] "    org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)"                                                     
[19] "    org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)"                                                         
[20] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"                                                 
[21] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"                                                       
[22] "    water.webserver.jetty8.Jetty8ServerAdapter$LoginHandler.handle(Jetty8ServerAdapter.java:119)"                                          
[23] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"                                                 
[24] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"                                                       
[25] "    org.eclipse.jetty.server.Server.handle(Server.java:370)"                                                                               
[26] "    org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)"                                        
[27] "    org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)"                                         
[28] "    org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:984)"                                              
[29] "    org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1045)"                              
[30] "    org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)"                                                                      
[31] "    org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:236)"                                                                 
[32] "    org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)"                                                
[33] "    org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)"                                          
[34] "    org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)"                                                      
[35] "    org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:543)"                                                       
[36] "    java.lang.Thread.run(Thread.java:748)"                                                                                                 

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


ERROR MESSAGE:

Provided column type ordered is unknown.  Cannot proceed with parse due to invalid argument.

不是很清楚哪里出了问题。

diamonds 数据集(至少来自 ggplot2 的数据集)包括 ordered class:

的变量
> str(diamonds)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   53940 obs. of  10 variables:
 $ carat  : num  0.23 0.21 0.23 0.29 0.31 0.24 0.24 0.26 0.22 0.23 ...
 $ cut    : Ord.factor w/ 5 levels "Fair"<"Good"<..: 5 4 2 4 2 3 3 3 1 3 ...
 $ color  : Ord.factor w/ 7 levels "D"<"E"<"F"<"G"<..: 2 2 2 6 7 7 6 5 2 5 ...
 $ clarity: Ord.factor w/ 8 levels "I1"<"SI2"<"SI1"<..: 2 3 5 4 2 6 7 3 4 5 ...
 $ depth  : num  61.5 59.8 56.9 62.4 63.3 62.8 62.3 61.9 65.1 59.4 ...
 $ table  : num  55 61 65 58 58 57 57 55 61 61 ...
 $ price  : int  326 326 327 334 335 336 336 337 337 338 ...
 $ x      : num  3.95 3.89 4.05 4.2 4.34 3.94 3.95 4.07 3.87 4 ...
 $ y      : num  3.98 3.84 4.07 4.23 4.35 3.96 3.98 4.11 3.78 4.05 ...
 $ z      : num  2.43 2.31 2.31 2.63 2.75 2.48 2.47 2.53 2.49 2.39 ...

> sapply(diamonds, class)
$carat
[1] "numeric"

$cut
[1] "ordered" "factor" 

$color
[1] "ordered" "factor" 

$clarity
[1] "ordered" "factor" 

$depth
[1] "numeric"

$table
[1] "numeric"

$price
[1] "integer"

$x
[1] "numeric"

$y
[1] "numeric"

$z
[1] "numeric"

错误消息似乎表明 h2o 不支持 class。您应该首先将它们转换为不同的 class,例如factorcharacter.