-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathh2o_benchmark.R
51 lines (40 loc) · 1.4 KB
/
h2o_benchmark.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
library(h2o)
localH2O <- h2o.init(nthread=4,Xmx="6g")
train <- read.csv("Data/train.csv")
for(i in 2:94){
train[,i] <- as.numeric(train[,i])
train[,i] <- sqrt(train[,i]+(3/8))
}
test <- read.csv("Data/test.csv")
for(i in 2:94){
test[,i] <- as.numeric(test[,i])
test[,i] <- sqrt(test[,i]+(3/8))
}
train.hex <- as.h2o(localH2O,train)
test.hex <- as.h2o(localH2O,test[,2:94])
predictors <- 2:(ncol(train.hex)-1)
response <- ncol(train.hex)
submission <- read.csv("Data/sampleSubmission.csv")
submission[,2:10] <- 0
for(i in 1:20){
print(i)
model <- h2o.deeplearning(x=predictors,
y=response,
data=train.hex,
classification=T,
activation="RectifierWithDropout",
hidden=c(1024,512,256),
hidden_dropout_ratio=c(0.5,0.5,0.5),
input_dropout_ratio=0.05,
epochs=50,
l1=1e-5,
l2=1e-5,
rho=0.99,
epsilon=1e-8,
train_samples_per_iteration=2000,
max_w2=10,
seed=1337)
submission[,2:10] <- submission[,2:10] + as.data.frame(h2o.predict(model,test.hex))[,2:10]
print(i)
write.csv(submission,file="Output/h2o_submission_2.csv",row.names=FALSE)
}