无法将数据帧转换为h2o对象 [英] Unable to convert data frame to h2o object
问题描述
我想在R中设置本地集群,按照本教程的步骤: http://blenditbayes.blogspot.co.uk/2014 /07/things-to-try-after-user-part-1-deep.html
第一步似乎不是一个问题。似乎是一个问题是将我的数据框转换为一个正确的h2o对象。
library(mlbench)
pre>
dat = BreastCancer [, - 1]从mlbench包中数据集中的#reading
库(h2o)
localH2O< - h2o.init(ip =localhost,port = 54321, startH2O = TRUE)#sets up the cluster
dat_h2o< - as.h2o(localH2O,dat,key ='dat')#this返回错误消息
上述语句as.h2o导致以下错误消息
as.h2o(localH2O,dat,key =dat)中的错误:
未使用参数(key =dat)
如果我删除key参数,让数据位于机器生成名称下的H2O键值存储中,将出现以下错误消息。
.h2o.doSafeREST中的错误(conn = conn,h2oRestApiVersion = h2oRestApiVersion,
意外的CURL错误:来自服务器的空答复
<一个href =http://stackoverflow.com/questions/27553362/how-to-convert-r-data-frame-to-h2o-object>这个问题和我一样,但是解决方案导致我出现同样的错误。
有没有人有这个问题的经验?我不完全确定如何处理这个问题。
解决方案最后稳定释放H2O-Classic和最新稳定释放的H2O-3.0。我相信你使用了一个H2O-3.0版本,这意味着函数中的一些参数已经改变了,模糊的key参数已经更改为destination_frame。
H2O-3.0的行为会有所不同,因为它将注意到前5列是R数据帧中的有序因子;目前我们没有办法保留分类栏的订单。但是,要重现与 http://blenditbayes.blogspot.co.uk/2014/07/things-to-try-after-user-part-1-deep.html ,你必须现在将框架作为CSV写入磁盘并将其导入到H2O中。
library(mlbench)
dat = BreastCancer [,-1]#数据集中的数据从mlbench包
库(h2o)
localH2O < - h2o.init(ip =localhost,port = 54321,startH2O = TRUE )
#dat_h2o< - as.h2o(dat,destination_frame ='dat')
##将返回一个提供的列类型c(有序,枚举)是未知。
pathToData< - paste0(normalizePath(〜/ Downloads /),/dat.csv)
write.table(x = dat,file = pathToData,row。 name = F,col.names = T)
dat_h2o< - h2o.importFile(path = pathToData,destination_frame =dat)
对于没有排序因子列的R data.frames,您可以简单地使用
h2o_frame< - as.h2o(object = df)
其中class(df)
是一个data.frame
。I am running the h2o package in Rstudio Version 0.99.447. I run version 10.9.5 OSX.
I would like to set up a local cluster within R, following the steps of this tutorial: http://blenditbayes.blogspot.co.uk/2014/07/things-to-try-after-user-part-1-deep.html
The first step does not seem to be a problem. What does seem to be a problem is converting my data frame to a proper h2o object.
library(mlbench) dat = BreastCancer[,-1] #reading in data set from mlbench package library(h2o) localH2O <- h2o.init(ip = "localhost", port = 54321, startH2O = TRUE) #sets up the cluster dat_h2o <- as.h2o(localH2O, dat, key = 'dat') #this returns an error message
The above statement as.h2o results in the following error message
Error in as.h2o(localH2O, dat, key = "dat") : unused argument (key = "dat")
If I remove the "key" parameter, letting the data reside in the H2O key-value store under a machine generated name, the following error message comes up.
Error in .h2o.doSafeREST(conn = conn, h2oRestApiVersion = h2oRestApiVersion, Unexpected CURL error: Empty reply from server
This question asks the same thing as me, but the solution leads me to the same error.
Does anyone have experience with this problem? I'm not entirely sure how to approach this.
解决方案The syntax for importing a frame from R into H2O has changed since the last stable release of H2O-Classic and the latest stable release of H2O-3.0. I believe you used a H2O-3.0 release which means some of the arguments in the functions has since changed, the ambiguous "key" argument has been changed to "destination_frame".
H2O-3.0 will behave differently in that it will make note that the first 5 columns are ordered factors in the R data frame; and at the moment we don't have a way of preserving orders for categorical columns. However, to reproduce the same results as the one posted on http://blenditbayes.blogspot.co.uk/2014/07/things-to-try-after-user-part-1-deep.html you'll have to for now write the frame to disk as a CSV and import it into H2O.
library(mlbench) dat = BreastCancer[,-1] #reading in data set from mlbench package library(h2o) localH2O <- h2o.init(ip = "localhost", port = 54321, startH2O = TRUE) #dat_h2o <- as.h2o(dat, destination_frame = 'dat') ## Will return a "Provided column type c("ordered", "enum") is unknown." error pathToData <- paste0(normalizePath("~/Downloads/"), "/dat.csv") write.table(x = dat, file = pathToData, row.names = F, col.names = T) dat_h2o <- h2o.importFile(path = pathToData, destination_frame = "dat")
For R data.frames that do not have ordered factor columns you can simply use
h2o_frame <- as.h2o(object = df)
whereclass(df)
is adata.frame
.这篇关于无法将数据帧转换为h2o对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!