syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

Question:
In H2O how to start your first DeepLearning Demo?

I captured a screendump of my first attempt to run an H2O DeepLearning Demo:
dan@feb ~ $ 
dan@feb ~ $ 
dan@feb ~ $ cd /tmp
dan@feb /tmp $ 
dan@feb /tmp $ wget http://s3.amazonaws.com/h2o-release/h2o/master/1694/h2o-2.9.0.1694.zip
--2015-02-12 23:17:05--  http://s3.amazonaws.com/h2o-release/h2o/master/1694/h2o-2.9.0.1694.zip
Resolving s3.amazonaws.com (s3.amazonaws.com)... 54.231.244.0
Connecting to s3.amazonaws.com (s3.amazonaws.com)|54.231.244.0|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 145574809 (139M) [application/zip]
Saving to: ‘h2o-2.9.0.1694.zip’

100%[======================================>] 145,574,809 1.69MB/s   in 56s    

2015-02-12 23:18:02 (2.46 MB/s) - ‘h2o-2.9.0.1694.zip’ saved [145574809/145574809]

dan@feb /tmp $ unzip h2o-2.9.0.1694.zip 
Archive:  h2o-2.9.0.1694.zip
   creating: h2o-2.9.0.1694/
  inflating: h2o-2.9.0.1694/h2o-sources.jar  
   creating: h2o-2.9.0.1694/hadoop/
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_hdp2.0.6.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_mapr2.1.3.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_mapr4.0.1.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_cdh4_yarn.jar  
  inflating: h2o-2.9.0.1694/hadoop/README.txt  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_cdh5.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_hdp2.1.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_cdh3.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_hdp1.3.2.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_hdp2.2.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_cdh4.jar  
  inflating: h2o-2.9.0.1694/hadoop/h2odriver_mapr3.1.1.jar  
   creating: h2o-2.9.0.1694/ec2/
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-distribute-h2o.sh  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-distribute-flatfile.sh  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-print-info.py  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-launch-instances.py  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-test-ssh.sh  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-distribute-aws-credentials.sh  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-download-h2o.sh  
  inflating: h2o-2.9.0.1694/ec2/README.txt  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-stop-h2o.sh  
  inflating: h2o-2.9.0.1694/ec2/h2o-cluster-start-h2o.sh  
   creating: h2o-2.9.0.1694/tableau/
  inflating: h2o-2.9.0.1694/tableau/ClaimsTweedieAnalysis_8.2.twb  
  inflating: h2o-2.9.0.1694/tableau/Demo_Template_8.2.twb  
   creating: h2o-2.9.0.1694/tableau/meta_data/
  inflating: h2o-2.9.0.1694/tableau/meta_data/claims_metadata.csv  
  inflating: h2o-2.9.0.1694/tableau/meta_data/airlines_meta.csv  
  inflating: h2o-2.9.0.1694/tableau/meta_data/claims_coefficients.csv  
  inflating: h2o-2.9.0.1694/tableau/Demo_Template_8.1.twb  
  inflating: h2o-2.9.0.1694/tableau/TableauTutorial.docx  
   creating: h2o-2.9.0.1694/tableau/data/
  inflating: h2o-2.9.0.1694/tableau/data/claimsdata.csv.tar.xz  
  inflating: h2o-2.9.0.1694/README.txt  
   creating: h2o-2.9.0.1694/spark/
  inflating: h2o-2.9.0.1694/spark/README.txt  
   creating: h2o-2.9.0.1694/R/
  inflating: h2o-2.9.0.1694/R/README.txt  
  inflating: h2o-2.9.0.1694/R/h2o_2.9.0.1694.tar.gz  
  inflating: h2o-2.9.0.1694/h2o.jar  
  inflating: h2o-2.9.0.1694/LICENSE.txt  
  inflating: h2o-2.9.0.1694/h2o-model.jar  
dan@feb /tmp $ 
dan@feb /tmp $ 
dan@feb /tmp $ ln -s h2o-2.9.0.1694 h2o
dan@feb /tmp $ 
dan@feb /tmp $ cd h2o
dan@feb /tmp/h2o $ 
dan@feb /tmp/h2o $ 
dan@feb /tmp/h2o $ ll
total 90864
drwxr-xr-x  7 dan  dan      4096 Feb 11 23:03 ./
drwxrwxrwt 32 root root    12288 Feb 12 23:19 ../
drwxr-xr-x  2 dan  dan      4096 Feb 11 23:03 ec2/
-rw-r--r--  1 dan  dan  91502066 Feb 11 23:02 h2o.jar
-rw-r--r--  1 dan  dan      8138 Feb 11 23:01 h2o-model.jar
-rw-r--r--  1 dan  dan   1477730 Feb 11 23:02 h2o-sources.jar
drwxr-xr-x  2 dan  dan      4096 Feb 11 23:02 hadoop/
-rw-r--r--  1 dan  dan     11341 Feb 11 23:00 LICENSE.txt
drwxr-xr-x  2 dan  dan      4096 Feb 11 23:03 R/
-rw-r--r--  1 dan  dan      1804 Feb 11 23:00 README.txt
drwxr-xr-x  2 dan  dan      4096 Feb 11 23:03 spark/
drwxr-xr-x  4 dan  dan      4096 Feb 11 23:03 tableau/
dan@feb /tmp/h2o $ 
dan@feb /tmp/h2o $ 
dan@feb /tmp/h2o $ 


dan@feb /tmp/h2o $ 
dan@feb /tmp/h2o $ cd R
dan@feb /tmp/h2o/R $ 
dan@feb /tmp/h2o/R $ ll
total 40424
drwxr-xr-x 2 dan dan     4096 Feb 11 23:03 ./
drwxr-xr-x 7 dan dan     4096 Feb 11 23:03 ../
-rw-r--r-- 1 dan dan 41378572 Feb 11 23:03 h2o_2.9.0.1694.tar.gz
-rw-r--r-- 1 dan dan     1624 Feb 11 23:00 README.txt
dan@feb /tmp/h2o/R $ 
dan@feb /tmp/h2o/R $ 



dan@feb /tmp/h2o/R $ R

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
> 
> remove.packages('h2o')
Removing package from ‘/home/dan/rdir/lib/R/library’
(as ‘lib’ is unspecified)
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> 

> > install.packages("h2o_2.9.0.1694.tar.gz", repos = NULL, type = "source")
* installing *source* package ‘h2o’ ...
** R
** demo
** inst
** preparing package for lazy loading
Creating a generic function for ‘summary’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘colnames’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘t’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘colnames<-’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘nrow’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘ncol’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘sd’ from package ‘stats’ in package ‘h2o’
Creating a generic function for ‘var’ from package ‘stats’ in package ‘h2o’
Creating a generic function for ‘as.factor’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘is.factor’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘which’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘levels’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘apply’ from package ‘base’ in package ‘h2o’
Creating a generic function for ‘findInterval’ from package ‘base’ in package ‘h2o’
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (h2o)
> 



> library(h2o)
Loading required package: statmod
Loading required package: survival
Loading required package: splines

----------------------------------------------------------------------

Your next step is to start H2O and get a connection object (named
'localH2O', for example):
    > localH2O = h2o.init()

For H2O package documentation, ask for help:
    > ??h2o

After starting H2O, you can use the Web UI at http://localhost:54321
For more information visit http://docs.0xdata.com

----------------------------------------------------------------------


Attaching package: ‘h2o’

The following objects are masked from ‘package:base’:

    ifelse, max, min, strsplit, sum, tolower, toupper

> 
> 
> localH2O = h2o.init()

H2O is not running yet, starting it now...

Note:  In case of errors look at the following log files:
    /tmp/Rtmp1UU8rI/h2o_dan_started_from_r.out
    /tmp/Rtmp1UU8rI/h2o_dan_started_from_r.err

java version "1.7.0_60-ea"
Java(TM) SE Runtime Environment (build 1.7.0_60-ea-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

Successfully connected to http://127.0.0.1:54321 

R is connected to H2O cluster:
    H2O cluster uptime:         5 seconds 360 milliseconds 
    H2O cluster version:        2.9.0.1694 
    H2O cluster name:           H2O_started_from_R 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   0.86 GB 
    H2O cluster total cores:    3 
    H2O cluster allowed cores:  2 
    H2O cluster healthy:        TRUE 

Note:  As started, H2O is limited to the CRAN default of 2 CPUs.
       Shut down and restart H2O as shown below to use all your CPUs.
           > h2o.shutdown(localH2O)
           > localH2O = h2o.init(nthreads = -1)

> 
> 
> irisPath = system.file("extdata", "iris.csv", package = "h2o")
> 
> iris.hex = h2o.importFile(localH2O, path = irisPath)
  |======================================================================| 100%
> 
> head(iris.hex)
   C1  C2  C3  C4          C5
1 5.1 3.5 1.4 0.2 Iris-setosa
2 4.9 3.0 1.4 0.2 Iris-setosa
3 4.7 3.2 1.3 0.2 Iris-setosa
4 4.6 3.1 1.5 0.2 Iris-setosa
5 5.0 3.6 1.4 0.2 Iris-setosa
6 5.4 3.9 1.7 0.4 Iris-setosa
> 
> 
> dlm = h2o.deeplearning(x = 1:4, y = 5, data = iris.hex, activation = "Tanh",hidden = c(10, 10), epochs = 5)
  |======================================================================| 100%
> 
> dlm
IP Address: 127.0.0.1 
Port      : 54321 
Parsed Data Key: iris.hex 

Deep Learning Model Key: DeepLearning_a5b1e031bab8ecc6486fd3b3f34148ab

Training classification error: 0.09333333

Validation classification error: 1

Confusion matrix:
Reported on iris.hex 
                 Predicted
Actual            Iris-setosa Iris-versicolor Iris-virginica   Error
  Iris-setosa              50               0              0 0.00000
  Iris-versicolor           0              41              9 0.18000
  Iris-virginica            0               5             45 0.10000
  Totals                   50              46             54 0.09333
> 
> 
> row1x = iris.hex[1,1:4]
> 
> row1x
IP Address: 127.0.0.1 
Port      : 54321 
Parsed Data Key: Last.value.1 

   C1  C2  C3  C4
1 5.1 3.5 1.4 0.2
> 
> 
> myprediction = h2o.predict(object = dlm, newdata = row1x)
> 
> myprediction
IP Address: 127.0.0.1 
Port      : 54321 
Parsed Data Key: DeepLearningPredict_b5ebcb888bb84e8bb7405657756b19dc 

      predict Iris.setosa Iris.versicolor Iris.virginica
1 Iris-setosa   0.9901745     0.007742027    0.002083505
> 
> # done
> 
Save workspace image? [y/n/c]: n
dan@feb /tmp/h2o/R $ 
dan@feb /tmp/h2o/R $ 



syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me