forked from h2oai/h2o-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
H2OTestDemo.R
47 lines (42 loc) · 1.82 KB
/
H2OTestDemo.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
# Test R functionality for Demo
# to invoke this you need R 2.15 as of now
# R -f H2OTestDemo.R
source("../R/H2O.R")
h2o.SERVER="localhost:54321"
# Run expressions on covtype
# h2o.importFile("covtype", paste(getwd(), "../smalldata/covtype/covtype.20k.data", sep="/"))
h2o.importUrl("covtype", "http://www.stanford.edu/~anqif/covtype.20k.data")
h2o.inspect(covtype.hex)
#h2o(slice(covtype.hex,100,100))
#h2o(sum(covtype.hex[12]))
# h2o.glm(covtype.hex, y = 12, case="1",family=binomial)
# h2o.glm(covtype.hex, y = 12, x = "1,2,3,4,5,6,7,8",case=1, family=binomial)
temp <- h2o.glm(covtype.hex, y = 12, case = "1", family = binomial)
cov.glm1 <- h2o.inspect_glm(temp$destination_key)
cov.glm1$coef
cov.glm1$dof
temp <- h2o.glm(covtype.hex, y = 12, x = "1,2,3,4,5,6,7,8", case = 1, family = binomial)
cov.glm2 <- h2o.inspect_glm(temp$destination_key)
cov.glm2$coef
cov.glm2$dof
#h2o.filter(covtype.hex, covtype.hex[6] < mean(covtype.hex[6]))
#h2o(covtype[1] + covtype[2] * 4 + max(covtype[6]) * covtype[1] + 7 - covtype[3])
#h2o(log(covtype[1]))
# add randomforest test
# h2o.rf(covtype.hex, class = "54", ntree = "10")
temp <- h2o.rf(covtype.hex, class = "54", ntree = "10")
cov.rf <- h2o.inspect_rf(temp$model_key, temp$data_key)
cov.rf
# Run GLM
# h2o.importFile("prostate", paste(getwd(),"../smalldata/logreg/prostate.csv",sep="/"))
h2o.importUrl("prostate", "http://www.stanford.edu/~anqif/prostate.csv")
h2o.inspect(prostate.hex)
# h2o.glm(prostate.hex, y = CAPSULE, x = "ID,AGE,RACE,PSA,DCAPS", family=binomial)
temp <- h2o.glm(prostate.hex, y = CAPSULE, x = "ID,AGE,RACE,PSA,DCAPS", family = binomial)
prostate.glm <- h2o.inspect_glm(temp$destination_key)
prostate.glm$coef
prostate.glm$dof
# Run K-Means
temp <- h2o.kmeans(covtype.hex, k = 10)
cov.km <- h2o.inspect_kmeans(temp$destination_key)
cov.km