Skip to content

Instantly share code, notes, and snippets.

@HackerEarthBlog
Last active February 1, 2017 15:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HackerEarthBlog/b8e07fee9bdc3e5ac4dbd0b1f0245bc0 to your computer and use it in GitHub Desktop.
Save HackerEarthBlog/b8e07fee9bdc3e5ac4dbd0b1f0245bc0 to your computer and use it in GitHub Desktop.
#load the package
require(h2o)
#start h2o
localH2o <- h2o.init(nthreads = -1, max_mem_size = "20G")
#load data on H2o
trainh2o <- as.h2o(train)
testh2o <- as.h2o(test)
#set variables
y <- "target"
x <- setdiff(colnames(trainh2o),y)
#train the model - without hidden layer
deepmodel <- h2o.deeplearning(x = x
,y = y
,training_frame = trainh2o
,standardize = T
,model_id = "deep_model"
,activation = "Rectifier"
,epochs = 100
,seed = 1
,nfolds = 5
,variable_importances = T)
#compute variable importance and performance
h2o.varimp_plot(deepmodel,num_of_features = 20)
h2o.performance(deepmodel,xval = T) #84.5 % CV accuracy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment