Skip to content

Instantly share code, notes, and snippets.

@HackerEarthBlog
Last active January 31, 2017 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HackerEarthBlog/94ffe14fa6bd6175c3fec6d9717378a7 to your computer and use it in GitHub Desktop.
Save HackerEarthBlog/94ffe14fa6bd6175c3fec6d9717378a7 to your computer and use it in GitHub Desktop.
#set parameter space
activation_opt <- c("Rectifier","RectifierWithDropout", "Maxout","MaxoutWithDropout")
hidden_opt <- list(c(10,10),c(20,15),c(50,50,50))
l1_opt <- c(0,1e-3,1e-5)
l2_opt <- c(0,1e-3,1e-5)
hyper_params <- list( activation=activation_opt,
hidden=hidden_opt,
l1=l1_opt,
l2=l2_opt )
#set search criteria
search_criteria <- list(strategy = "RandomDiscrete", max_models=10)
#train model
dl_grid <- h2o.grid("deeplearning"
,grid_id = "deep_learn"
,hyper_params = hyper_params
,search_criteria = search_criteria
,training_frame = trainh2o
,x=x
,y=y
,nfolds = 5
,epochs = 100)
#get best model
d_grid <- h2o.getGrid("deep_learn",sort_by = "accuracy")
best_dl_model <- h2o.getModel(d_grid@model_ids[[1]])
h2o.performance (best_dl_model,xval = T) #CV Accuracy - 84.7%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment