2017-07-26 55 views
1

我試圖使用as.h2o函數將R數據轉換爲h2o數據。來自as.h2o的對象在R中有一點觀察

然而,由as.h2o函數變換觀測值的數目減少到10

有在我的數據共計1000個觀測。有700個列車數據和300個測試數據。但是,使用as.h2o函數只有10個觀測值。

以下是我的完整和開源代碼。你可以使用它。請幫幫我。

爲什麼轉換爲h2o數據的數據有10個觀測值?

install.packages("h2o") 
library(h2o) 
h2o.init(max_mem_size = "10G", nthreads = -1) 

df<-read.csv("http://freakonometrics.free.fr/german_credit.csv", header=TRUE) 
F=c(1,2,4,5,7,8,9,10,11,12,13,15,16,17,18,19,20,21) 
for(i in F) df[,i]=as.factor(df[,i]) 

library(caret) 

set.seed(1000) 
intrain<-createDataPartition(y=df$Creditability, p=0.7, list=FALSE) 
train<-df[intrain, ] 
test<-df[-intrain, ] 
str(train) 
str(test) 

h2o_train<-as.h2o(train, destination_frame = "h2o_train") 
h2o_test<-as.h2o(test, destination_frame = "h2o_test") 
str(h2o_train) 
str(h2o_test) 

回答

1

這似乎是一個古怪str()顯示H2OFrames,而不是一個實際的問題是如何。如果您查看流量(localhost:54321)或在h2o對象上調用nrow(),您將看到您期望的結果。

+0

這是僅在打印輸出中的錯誤。看看'nrow(h2o_train)'來驗證大小。我在這裏提交了一個錯誤報告:https:/ 0xdata.atlassian.net/browse/PUBDEV-4742 –