library(caret)
## Loading required package: lattice
## Loading required package: ggplot2
library(wikipediatrend)
views<-wp_trend(page = "Citigroup",from = "2010-01-01",to = "2014-12-31",lang = "en",friendly = TRUE,requestFrom = "wp.trend.tester at wptt.wptt",userAgent = TRUE)
## Option 'requestFrom' is deprecated and will cause errors 
##             in futuere versions of the wp_trend() function. Please read 
##             the package vignette and/or README to learn about the new
##             set of options.
##             
##             Check wp_http_header() to know which information are send to 
##             stats.grok.se (R and package versions)
##             
## Option 'friendly' is deprecated and will cause errors 
##             in futuere versions of the wp_trend() function. Please read 
##             the package vignette and/or README to learn about the new
##             set of options.
##             
##             The package now is friendly by default.
##             
## Option 'userAgent' is deprecated and will cause errors 
##             in futuere versions of the wp_trend() function. Please read 
##             the package vignette and/or README to learn about the new
##             set of options.
##             
##             Check wp_http_header() to know which information are send to 
##             stats.grok.se (R and package versions)
##             
## http://stats.grok.se/json/en/201001/Citigroup
## http://stats.grok.se/json/en/201002/Citigroup
## http://stats.grok.se/json/en/201003/Citigroup
## http://stats.grok.se/json/en/201004/Citigroup
## http://stats.grok.se/json/en/201005/Citigroup
## http://stats.grok.se/json/en/201006/Citigroup
## http://stats.grok.se/json/en/201007/Citigroup
## http://stats.grok.se/json/en/201008/Citigroup
## http://stats.grok.se/json/en/201009/Citigroup
## http://stats.grok.se/json/en/201010/Citigroup
## http://stats.grok.se/json/en/201011/Citigroup
## http://stats.grok.se/json/en/201012/Citigroup
## http://stats.grok.se/json/en/201101/Citigroup
## http://stats.grok.se/json/en/201102/Citigroup
## http://stats.grok.se/json/en/201103/Citigroup
## http://stats.grok.se/json/en/201104/Citigroup
## http://stats.grok.se/json/en/201105/Citigroup
## http://stats.grok.se/json/en/201106/Citigroup
## http://stats.grok.se/json/en/201107/Citigroup
## http://stats.grok.se/json/en/201108/Citigroup
## http://stats.grok.se/json/en/201109/Citigroup
## http://stats.grok.se/json/en/201110/Citigroup
## http://stats.grok.se/json/en/201111/Citigroup
## http://stats.grok.se/json/en/201112/Citigroup
## http://stats.grok.se/json/en/201201/Citigroup
## http://stats.grok.se/json/en/201202/Citigroup
## http://stats.grok.se/json/en/201203/Citigroup
## http://stats.grok.se/json/en/201204/Citigroup
## http://stats.grok.se/json/en/201205/Citigroup
## http://stats.grok.se/json/en/201206/Citigroup
## http://stats.grok.se/json/en/201207/Citigroup
## http://stats.grok.se/json/en/201208/Citigroup
## http://stats.grok.se/json/en/201209/Citigroup
## http://stats.grok.se/json/en/201210/Citigroup
## http://stats.grok.se/json/en/201211/Citigroup
## http://stats.grok.se/json/en/201212/Citigroup
## http://stats.grok.se/json/en/201301/Citigroup
## http://stats.grok.se/json/en/201302/Citigroup
## http://stats.grok.se/json/en/201303/Citigroup
## http://stats.grok.se/json/en/201304/Citigroup
## http://stats.grok.se/json/en/201305/Citigroup
## http://stats.grok.se/json/en/201306/Citigroup
## http://stats.grok.se/json/en/201307/Citigroup
## http://stats.grok.se/json/en/201308/Citigroup
## http://stats.grok.se/json/en/201309/Citigroup
## http://stats.grok.se/json/en/201310/Citigroup
## http://stats.grok.se/json/en/201311/Citigroup
## http://stats.grok.se/json/en/201312/Citigroup
## http://stats.grok.se/json/en/201401/Citigroup
## http://stats.grok.se/json/en/201402/Citigroup
## http://stats.grok.se/json/en/201403/Citigroup
## http://stats.grok.se/json/en/201404/Citigroup
## http://stats.grok.se/json/en/201405/Citigroup
## http://stats.grok.se/json/en/201406/Citigroup
## http://stats.grok.se/json/en/201407/Citigroup
## http://stats.grok.se/json/en/201408/Citigroup
## http://stats.grok.se/json/en/201409/Citigroup
## http://stats.grok.se/json/en/201410/Citigroup
## http://stats.grok.se/json/en/201411/Citigroup
## http://stats.grok.se/json/en/201412/Citigroup
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
startDate = as.Date("2010-01-01")

endDate = as.Date("2014-12-31") 

getSymbols("c", src = "yahoo", from = startDate, to = endDate) 
##     As of 0.4-0, 'getSymbols' uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption("getSymbols.env") and 
##  getOptions("getSymbols.auto.assign") are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.
## [1] "C"
RSI3<-RSI(Op(C), n= 3) 
#Calculate a 3-period relative strength index (RSI) off the open price

EMA5<-EMA(Op(C),n=5) 
#Calculate a 5-period exponential moving average (EMA)
EMAcross<- Op(C)-EMA5 
#Let’s explore the difference between the open price and our 5-period EMA


DEMA10<-DEMA(Cl(C),n = 10, v = 1, wilder = FALSE)
DEMA10c<-Cl(C) - DEMA10

MACD<-MACD(Op(C),fast = 12, slow = 26, signal = 9) 
#Calculate a MACD with standard parameters

MACDsignal<-MACD[,2] 
#Grab just the signal line to use as our indicator.


SMI<-SMI(Op(C),n=13,slow=25,fast=2,signal=9) 
#Stochastic Oscillator with standard parameters
SMI<-SMI[,1] 
#Grab just the oscillator to use as our indicator

BB<-BBands(Op(C),n=20,sd=2)
BBp<-BB[,4]


CCI20<-CCI(C[,3:5],n=20)
#A 20-period Commodity Channel Index calculated of the High/Low/Close of our data



PriceChange<- Cl(C) - Op(C) 
#Calculate the difference between the close price and open price
Class<-ifelse(PriceChange>0,"UP","DOWN") 
#Create a binary classification variable, the variable we are trying to predict.

DJIADF<-data.frame(date = index(C), C, row.names=NULL)


CombDF<-merge(views,DJIADF, by.x='date', by.y='date')

DataSet<-data.frame(RSI3,EMAcross,MACDsignal,SMI,BBp,CCI20,DEMA10c) 



DataSet<-DataSet[-c(1:33),] 

Alldata<-cbind(DataSet,CombDF[34:1258,2])


Normalized <-function(x) {(x-min(x))/(max(x)-min(x))}
NormalizedData<-as.data.frame(lapply(Alldata,Normalized))

ClassDF<-data.frame(date = index(Class), Class, row.names=NULL)

AlldataNormalized<-data.frame(NormalizedData,ClassDF[34:1258,2])


colnames(AlldataNormalized)<-c("RSI3","EMAcross","MACDsignal","SMI","BBp","CCI20","DEMA10c","Views","Class") 


TrainingSet<-AlldataNormalized[1:1000,] 

TestSet<-AlldataNormalized[1001:1225,]
TrainClass<-TrainingSet[,9] 
TrainPred<-TrainingSet[,-9] 

TestClass<-TestSet[,9] 
TestPred<-TestSet[,-9] 
library(h2o)
## Loading required package: statmod
## 
## ----------------------------------------------------------------------
## 
## Your next step is to start H2O:
##     > 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.h2o.ai
## 
## ----------------------------------------------------------------------
## 
## 
## Attaching package: 'h2o'
## 
## The following objects are masked from 'package:stats':
## 
##     sd, var
## 
## The following objects are masked from 'package:base':
## 
##     %*%, apply, as.factor, as.numeric, colnames, colnames<-,
##     ifelse, %in%, is.factor, is.numeric, log, trunc
localH2O <- h2o.init(ip = "localhost", port = 54321, startH2O = TRUE)
## Successfully connected to http://localhost:54321/ 
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         26 minutes 10 seconds 
##     H2O cluster version:        3.6.0.8 
##     H2O cluster name:           H2O_started_from_R_mitra2_ogx890 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   0.66 GB 
##     H2O cluster total cores:    4 
##     H2O cluster allowed cores:  2 
##     H2O cluster healthy:        TRUE
localH2O = h2o.init(ip = "localhost", port = 54321, startH2O = TRUE, 
                    Xmx = '2g')
## Warning in h2o.init(ip = "localhost", port = 54321, startH2O = TRUE, Xmx =
## "2g"): Xmx is a deprecated parameter. Use `max_mem_size` and `min_mem_size`
## to set the memory boundaries. Using `Xmx` to set these.
## Successfully connected to http://localhost:54321/ 
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         26 minutes 10 seconds 
##     H2O cluster version:        3.6.0.8 
##     H2O cluster name:           H2O_started_from_R_mitra2_ogx890 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   0.66 GB 
##     H2O cluster total cores:    4 
##     H2O cluster allowed cores:  2 
##     H2O cluster healthy:        TRUE
TrainH2o<-as.h2o(TrainingSet, destination_frame = "TrainH2o")
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |=================================================================| 100%
head(TrainH2o)
##        RSI3  EMAcross MACDsignal       SMI       BBp      CCI20   DEMA10c
## 1 0.9331516 0.1236991 0.09775004 0.3548534 0.6627022 0.14498935 0.1561449
## 2 0.9331516 0.1229697 0.10464865 0.4170325 0.6388570 0.18036729 0.1528981
## 3 0.3934442 0.1209599 0.11062878 0.4554274 0.5330026 0.19056025 0.1552461
## 4 0.5136515 0.1215789 0.11598789 0.4891637 0.5485061 0.17375920 0.1533669
## 5 0.5136515 0.1215562 0.12074544 0.5191934 0.5380094 0.12010509 0.1536277
## 6 0.7088161 0.1221941 0.12521381 0.5534579 0.5664558 0.09677432 0.1533921
##       Views Class
## 1 0.2220165    UP
## 2 0.2130447  DOWN
## 3 0.1915409    UP
## 4 0.1693250  DOWN
## 5 0.1706067    UP
## 6 0.1815722  DOWN
TestH2o<-as.h2o(TestPred, destination_frame = "TestH2o")
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |=================================================================| 100%
Deeplearningmodel1 <- h2o.deeplearning(x = 1:8,y = 9,training_frame = TrainH2o, activation = "TanhWithDropout",hidden = c(50,50,50,100),epochs = 100)
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |====================                                             |  30%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |================================                                 |  50%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |==============================================                   |  70%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |==========================================================       |  90%
  |                                                                       
  |=================================================================| 100%
Deeplearningmodel2 <- h2o.deeplearning(x = 1:8,y = 9,training_frame = TrainH2o, activation = "Rectifier",hidden = c(50,50,50,200),epochs = 200)
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |==========                                                       |  15%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |================                                                 |  25%
  |                                                                       
  |====================                                             |  30%
  |                                                                       
  |=======================                                          |  35%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |=============================                                    |  45%
  |                                                                       
  |================================                                 |  50%
  |                                                                       
  |====================================                             |  55%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |==========================================                       |  65%
  |                                                                       
  |==============================================                   |  70%
  |                                                                       
  |=================================================                |  75%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |=======================================================          |  85%
  |                                                                       
  |==========================================================       |  90%
  |                                                                       
  |==============================================================   |  95%
  |                                                                       
  |=================================================================| 100%
Deeplearningmodel3 <- h2o.deeplearning(x = 1:8,y = 9,training_frame = TrainH2o, activation = "Tanh",hidden = c(100,100),epochs = 300)
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |==                                                               |   3%
  |                                                                       
  |====                                                             |   7%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |=========                                                        |  13%
  |                                                                       
  |===========                                                      |  17%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |===============                                                  |  23%
  |                                                                       
  |=================                                                |  27%
  |                                                                       
  |====================                                             |  30%
  |                                                                       
  |======================                                           |  33%
  |                                                                       
  |========================                                         |  37%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |============================                                     |  43%
  |                                                                       
  |==============================                                   |  47%
  |                                                                       
  |================================                                 |  50%
  |                                                                       
  |===================================                              |  53%
  |                                                                       
  |=====================================                            |  57%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |=========================================                        |  63%
  |                                                                       
  |===========================================                      |  67%
  |                                                                       
  |==============================================                   |  70%
  |                                                                       
  |================================================                 |  73%
  |                                                                       
  |==================================================               |  77%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |======================================================           |  83%
  |                                                                       
  |========================================================         |  87%
  |                                                                       
  |==========================================================       |  90%
  |                                                                       
  |=============================================================    |  93%
  |                                                                       
  |===============================================================  |  97%
  |                                                                       
  |=================================================================| 100%
Deeplearningmodel4 <- h2o.deeplearning(x = 1:8,y = 9,training_frame = TrainH2o, activation = "TanhWithDropout",hidden = c(100,100),epochs = 400)
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |==                                                               |   2%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |=====                                                            |   8%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |========                                                         |  12%
  |                                                                       
  |==========                                                       |  15%
  |                                                                       
  |===========                                                      |  18%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |===============                                                  |  22%
  |                                                                       
  |================                                                 |  25%
  |                                                                       
  |==================                                               |  28%
  |                                                                       
  |====================                                             |  30%
  |                                                                       
  |=====================                                            |  32%
  |                                                                       
  |=======================                                          |  35%
  |                                                                       
  |========================                                         |  38%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |============================                                     |  42%
  |                                                                       
  |=============================                                    |  45%
  |                                                                       
  |===============================                                  |  48%
  |                                                                       
  |================================                                 |  50%
  |                                                                       
  |==================================                               |  52%
  |                                                                       
  |====================================                             |  55%
  |                                                                       
  |=====================================                            |  57%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |=========================================                        |  62%
  |                                                                       
  |==========================================                       |  65%
  |                                                                       
  |============================================                     |  68%
  |                                                                       
  |==============================================                   |  70%
  |                                                                       
  |===============================================                  |  72%
  |                                                                       
  |=================================================                |  75%
  |                                                                       
  |==================================================               |  78%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |======================================================           |  82%
  |                                                                       
  |=======================================================          |  85%
  |                                                                       
  |=========================================================        |  88%
  |                                                                       
  |==========================================================       |  90%
  |                                                                       
  |============================================================     |  92%
  |                                                                       
  |==============================================================   |  95%
  |                                                                       
  |===============================================================  |  98%
  |                                                                       
  |=================================================================| 100%
h2o_yhat_test1 <- h2o.predict(Deeplearningmodel1,TestH2o)
df_yhat_test1 <- as.data.frame(h2o_yhat_test1)

h2o_yhat_test2 <- h2o.predict(Deeplearningmodel2,TestH2o)
df_yhat_test2 <- as.data.frame(h2o_yhat_test2)

h2o_yhat_test3 <- h2o.predict(Deeplearningmodel3,TestH2o)
df_yhat_test3 <- as.data.frame(h2o_yhat_test3)


h2o_yhat_test4 <- h2o.predict(Deeplearningmodel4,TestH2o)
df_yhat_test4 <- as.data.frame(h2o_yhat_test4)


DeepLearninPred1<-as.data.frame(df_yhat_test1[,1])
DeepLearninPred2<-as.data.frame(df_yhat_test2[,1])
DeepLearninPred3<-as.data.frame(df_yhat_test3[,1])
DeepLearninPred4<-as.data.frame(df_yhat_test4[,1])

Metrics on out of sample

prediction1 <-df_yhat_test1[,1] 


table(prediction1,TestClass)
##            TestClass
## prediction1 DOWN  UP
##        DOWN   91  15
##        UP     17 102
confusionMatrix(prediction1,TestClass)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction DOWN  UP
##       DOWN   91  15
##       UP     17 102
##                                           
##                Accuracy : 0.8578          
##                  95% CI : (0.8052, 0.9006)
##     No Information Rate : 0.52            
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.7149          
##  Mcnemar's Test P-Value : 0.8597          
##                                           
##             Sensitivity : 0.8426          
##             Specificity : 0.8718          
##          Pos Pred Value : 0.8585          
##          Neg Pred Value : 0.8571          
##              Prevalence : 0.4800          
##          Detection Rate : 0.4044          
##    Detection Prevalence : 0.4711          
##       Balanced Accuracy : 0.8572          
##                                           
##        'Positive' Class : DOWN            
## 
prediction2 <-df_yhat_test2[,1] 


table(prediction2,TestClass)
##            TestClass
## prediction2 DOWN  UP
##        DOWN  101  27
##        UP      7  90
confusionMatrix(prediction2,TestClass)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction DOWN  UP
##       DOWN  101  27
##       UP      7  90
##                                          
##                Accuracy : 0.8489         
##                  95% CI : (0.7953, 0.893)
##     No Information Rate : 0.52           
##     P-Value [Acc > NIR] : < 2e-16        
##                                          
##                   Kappa : 0.6994         
##  Mcnemar's Test P-Value : 0.00112        
##                                          
##             Sensitivity : 0.9352         
##             Specificity : 0.7692         
##          Pos Pred Value : 0.7891         
##          Neg Pred Value : 0.9278         
##              Prevalence : 0.4800         
##          Detection Rate : 0.4489         
##    Detection Prevalence : 0.5689         
##       Balanced Accuracy : 0.8522         
##                                          
##        'Positive' Class : DOWN           
## 
prediction3 <-df_yhat_test3[,1] 


table(prediction3,TestClass)
##            TestClass
## prediction3 DOWN UP
##        DOWN   92 21
##        UP     16 96
confusionMatrix(prediction3,TestClass)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction DOWN UP
##       DOWN   92 21
##       UP     16 96
##                                           
##                Accuracy : 0.8356          
##                  95% CI : (0.7805, 0.8815)
##     No Information Rate : 0.52            
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.6712          
##  Mcnemar's Test P-Value : 0.5108          
##                                           
##             Sensitivity : 0.8519          
##             Specificity : 0.8205          
##          Pos Pred Value : 0.8142          
##          Neg Pred Value : 0.8571          
##              Prevalence : 0.4800          
##          Detection Rate : 0.4089          
##    Detection Prevalence : 0.5022          
##       Balanced Accuracy : 0.8362          
##                                           
##        'Positive' Class : DOWN            
## 
prediction4 <-df_yhat_test4[,1] 


table(prediction4,TestClass)
##            TestClass
## prediction4 DOWN UP
##        DOWN   97 20
##        UP     11 97
confusionMatrix(prediction4,TestClass)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction DOWN UP
##       DOWN   97 20
##       UP     11 97
##                                           
##                Accuracy : 0.8622          
##                  95% CI : (0.8102, 0.9044)
##     No Information Rate : 0.52            
##     P-Value [Acc > NIR] : <2e-16          
##                                           
##                   Kappa : 0.7249          
##  Mcnemar's Test P-Value : 0.1508          
##                                           
##             Sensitivity : 0.8981          
##             Specificity : 0.8291          
##          Pos Pred Value : 0.8291          
##          Neg Pred Value : 0.8981          
##              Prevalence : 0.4800          
##          Detection Rate : 0.4311          
##    Detection Prevalence : 0.5200          
##       Balanced Accuracy : 0.8636          
##                                           
##        'Positive' Class : DOWN            
## 
  MetaData<-cbind(DeepLearninPred1,DeepLearninPred2,DeepLearninPred3,DeepLearninPred4,TestClass)
  colnames(MetaData)<-c("DeepLearninPred1","DeepLearninPred2","DeepLearninPred3","DeepLearninPred4","TestClass")
  
  
  MetaDataH2o<-as.h2o(MetaData, destination_frame = "MetaData")
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |=================================================================| 100%

ensemble meta level

MetaClass<-MetaData[,5] 

MetaPred<-MetaData[,-5] 

Deeplearningmodelmeta <- h2o.deeplearning(x = 1:3,y = 4,training_frame = MetaDataH2o, activation = "TanhWithDropout",hidden = c(50,50,50,100),epochs = 10000)
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |                                                                 |   1%
  |                                                                       
  |=                                                                |   1%
  |                                                                       
  |=                                                                |   2%
  |                                                                       
  |==                                                               |   2%
  |                                                                       
  |==                                                               |   3%
  |                                                                       
  |==                                                               |   4%
  |                                                                       
  |===                                                              |   4%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |====                                                             |   5%
  |                                                                       
  |====                                                             |   6%
  |                                                                       
  |====                                                             |   7%
  |                                                                       
  |=====                                                            |   7%
  |                                                                       
  |=====                                                            |   8%
  |                                                                       
  |======                                                           |   8%
  |                                                                       
  |======                                                           |   9%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |=======                                                          |  10%
  |                                                                       
  |=======                                                          |  11%
  |                                                                       
  |========                                                         |  12%
  |                                                                       
  |========                                                         |  13%
  |                                                                       
  |=========                                                        |  13%
  |                                                                       
  |=========                                                        |  14%
  |                                                                       
  |=========                                                        |  15%
  |                                                                       
  |==========                                                       |  15%
  |                                                                       
  |==========                                                       |  16%
  |                                                                       
  |===========                                                      |  16%
  |                                                                       
  |===========                                                      |  17%
  |                                                                       
  |===========                                                      |  18%
  |                                                                       
  |============                                                     |  18%
  |                                                                       
  |============                                                     |  19%
  |                                                                       
  |=================================================================| 100%
summary(Deeplearningmodelmeta)
## Model Details:
## ==============
## 
## H2OBinomialModel: deeplearning
## Model Key:  DeepLearning_model_R_1453199765449_50 
## Status of Neuron Layers: predicting DeepLearninPred4, 2-class classification, bernoulli distribution, CrossEntropy loss, 10,902 weights/biases, 135.3 KB, 429,750 training samples, mini-batch size 1
##   layer units        type dropout       l1       l2 mean_rate rate_RMS
## 1     1     9       Input  0.00 %                                     
## 2     2    50 TanhDropout 50.00 % 0.000000 0.000000  0.334743 0.466854
## 3     3    50 TanhDropout 50.00 % 0.000000 0.000000  0.000199 0.000093
## 4     4    50 TanhDropout 50.00 % 0.000000 0.000000  0.004020 0.003805
## 5     5   100 TanhDropout 50.00 % 0.000000 0.000000  0.038027 0.051878
## 6     6     2     Softmax         0.000000 0.000000  0.001639 0.000189
##   momentum mean_weight weight_RMS mean_bias bias_RMS
## 1                                                   
## 2 0.000000   -0.045485   1.659931 -0.064849 0.743728
## 3 0.000000    0.036474   2.127906 -0.065104 1.151216
## 4 0.000000    0.000183   0.787920  0.031078 0.421215
## 5 0.000000   -0.002099   0.221158 -0.005316 0.194145
## 6 0.000000    0.016725   0.388165 -0.001375 0.018936
## 
## H2OBinomialMetrics: deeplearning
## ** Reported on training data. **
## Description: Metrics reported on temporary (load-balanced) training frame
## 
## MSE:  0.05079234
## R^2:  0.7965051
## LogLoss:  0.2120665
## AUC:  0.9187638
## Gini:  0.8375277
## 
## Confusion Matrix for F1-optimal threshold:
##        DOWN  UP    Error     Rate
## DOWN    112   5 0.042735   =5/117
## UP        7 101 0.064815   =7/108
## Totals  119 106 0.053333  =12/225
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                       metric threshold    value idx
## 1                     max f1  0.954975 0.943925   0
## 2                     max f2  0.954975 0.938662   0
## 3               max f0point5  0.954975 0.949248   0
## 4               max accuracy  0.954975 0.946667   0
## 5              max precision  0.954975 0.952830   0
## 6           max absolute_MCC  0.954975 0.893228   0
## 7 max min_per_class_accuracy  0.954975 0.935185   0
## 
## 
## Scoring History: 
##              timestamp          duration training_speed     epochs
## 1  2016-01-19 12:06:04         0.000 sec                   0.00000
## 2  2016-01-19 12:06:05         0.501 sec  4591 rows/sec   10.00000
## 3  2016-01-19 12:06:10         5.520 sec  5729 rows/sec  140.00000
## 4  2016-01-19 12:06:15        10.619 sec  5525 rows/sec  260.00000
## 5  2016-01-19 12:06:20        15.787 sec  5573 rows/sec  390.00000
## 6  2016-01-19 12:06:25        20.930 sec  5711 rows/sec  530.00000
## 7  2016-01-19 12:06:30        26.149 sec  5778 rows/sec  670.00000
## 8  2016-01-19 12:06:36        31.322 sec  5832 rows/sec  810.00000
## 9  2016-01-19 12:06:41        36.323 sec  5960 rows/sec  960.00000
## 10 2016-01-19 12:06:46        41.620 sec  6068 rows/sec 1120.00000
## 11 2016-01-19 12:06:51        46.756 sec  6125 rows/sec 1270.00000
## 12 2016-01-19 12:06:56        51.977 sec  6204 rows/sec 1430.00000
## 13 2016-01-19 12:07:01        56.999 sec  6290 rows/sec 1590.00000
## 14 2016-01-19 12:07:07  1 min  2.246 sec  6340 rows/sec 1750.00000
## 15 2016-01-19 12:07:12  1 min  7.362 sec  6394 rows/sec 1910.00000
## 16 2016-01-19 12:07:12  1 min  7.385 sec  6394 rows/sec 1910.00000
##    iterations       samples training_MSE training_r2 training_logloss
## 1           0      0.000000                                          
## 2           1   2250.000000      0.05214     0.79110          0.30365
## 3          14  31500.000000      0.05286     0.78821          0.30866
## 4          26  58500.000000      0.05221     0.79083          0.24884
## 5          39  87750.000000      0.05199     0.79170          0.23988
## 6          53 119250.000000      0.05111     0.79523          0.21719
## 7          67 150750.000000      0.05099     0.79572          0.21526
## 8          81 182250.000000      0.05079     0.79651          0.21207
## 9          96 216000.000000      0.05328     0.78653          0.21779
## 10        112 252000.000000      0.05454     0.78148          0.22186
## 11        127 285750.000000      0.05475     0.78064          0.22467
## 12        143 321750.000000      0.05460     0.78123          0.22262
## 13        159 357750.000000      0.05459     0.78129          0.22241
## 14        175 393750.000000      0.05457     0.78135          0.22219
## 15        191 429750.000000      0.05462     0.78119          0.22279
## 16        191 429750.000000      0.05079     0.79651          0.21207
##    training_AUC training_classification_error
## 1                                            
## 2       0.98374                       0.05333
## 3       0.98334                       0.05333
## 4       0.97353                       0.05333
## 5       0.97353                       0.05333
## 6       0.97353                       0.05333
## 7       0.97353                       0.05333
## 8       0.91876                       0.05333
## 9       0.96569                       0.05333
## 10      0.96569                       0.05333
## 11      0.96569                       0.05333
## 12      0.96170                       0.05778
## 13      0.94195                       0.05778
## 14      0.94195                       0.05778
## 15      0.94195                       0.05778
## 16      0.91876                       0.05333
perf<-h2o.performance(Deeplearningmodelmeta)

perf@metrics$r2
## [1] 0.7965051
perf@metrics$AUC
## [1] 0.9187638
perf@metrics$max_criteria_and_metric_scores$value[4]
## [1] 0.9466667