Skip to content

Instantly share code, notes, and snippets.

@HackerEarthBlog
Last active February 1, 2017 15:04

Revisions

  1. HackerEarthBlog revised this gist Jan 31, 2017. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions DL2.H2o.R
    Original file line number Diff line number Diff line change
    @@ -2,18 +2,18 @@
    require(h2o)

    #start h2o
    localH2o = h2o.init(nthreads = -1, max_mem_size = "20G")
    localH2o <- h2o.init(nthreads = -1, max_mem_size = "20G")

    #load data on H2o
    trainh2o = as.h2o(train)
    testh2o = as.h2o(test)
    trainh2o <- as.h2o(train)
    testh2o <- as.h2o(test)

    #set variables
    y = "target"
    x = setdiff(colnames(trainh2o),y)
    y <- "target"
    x <- setdiff(colnames(trainh2o),y)

    #train the model - without hidden layer
    deepmodel = h2o.deeplearning(x = x
    deepmodel <- h2o.deeplearning(x = x
    ,y = y
    ,training_frame = trainh2o
    ,standardize = T
  2. HackerEarthBlog created this gist Jan 31, 2017.
    29 changes: 29 additions & 0 deletions DL2.H2o.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #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