9

我在 Rstudio 版本 0.99.447 中运行 h2o 包。我运行版本 10.9.5 OSX。

我想按照本教程的步骤在 R 中设置一个本地集群:http: //blenditbayes.blogspot.co.uk/2014/07/things-to-try-after-user-part-1-deep .html

第一步似乎没有问题。似乎有一个问题是将我的数据框转换为适当的 h2o 对象。

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

上述 as.h2o 语句导致以下错误消息

Error in as.h2o(localH2O, dat, key = "dat") : 
unused argument (key = "dat")

如果我删除“key”参数,让数据驻留在机器生成的名称下的 H2O 键值存储中,则会出现以下错误消息。

Error in .h2o.doSafeREST(conn = conn, h2oRestApiVersion = h2oRestApiVersion,  
Unexpected CURL error: Empty reply from server

这个问题和我问的一样,但解决方案导致我出现同样的错误。

有没有人有这个问题的经验?我不完全确定如何解决这个问题。

4

5 回答 5

11

自从 H2O-Classic 的最后一个稳定版本和 H2O-3.0 的最新稳定版本以来,将帧从 R 导入 H2O 的语法发生了变化。我相信您使用了 H2O-3.0 版本,这意味着函数中的某些参数已经更改,模棱两可的“关键”参数已更改为“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] #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")

对于没有有序因子列的 R data.frames,您可以简单地使用h2o_frame <- as.h2o(object = df)where class(df)is a data.frame

于 2015-07-20T20:44:51.187 回答
1

尝试这个。它对我有用。

## S3 method for class 'data.frame'
dat.hex <- as.h2o(dat, destination_frame = "dat.hex", ...)
于 2018-05-17T04:16:31.717 回答
1

The BreastCancer data frame has 5 ord.factors and 5 factors. As Amy Wang wrote, you have to convert factors into numeric. If you don't want to write data to disc and then to read again the data you can convert them with sapply().

## Format data with no factor
data(BreastCancer, package = 'mlbench') # Load data from mlbench package
dat <- BreastCancer[, -1]  # Remove the ID column
dat[, c(1:ncol(dat))] <- sapply(dat[, c(1:ncol(dat))], as.numeric) # Convert factors into numeric



## Start a local cluster with default parameters
library(h2o)
localH2O <- h2o.init(ip = "localhost", port = 54321, startH2O = TRUE)

## Convert Breast Cancer into H2O
dat.h2o <- as.h2o(dat, destination_frame = "midata")
于 2016-07-05T21:04:21.303 回答
0

我也面临同样的问题。在我的情况下,Mac OSX mavericks 上的问题 JAVA_HOME env 变量指向旧的 java 版本 6。我的解决方案是 h2o google groups stream here

于 2015-07-22T15:55:29.440 回答
0

你应该试试:

dat_h2o <- as.h2o(dat)

或者:

dat <- as.data.frame(dat)
dat_h2o <- as.h2o(dat)

希望这可以帮助!

于 2017-07-31T03:48:25.740 回答