Skip to content

Instantly share code, notes, and snippets.

@Emaasit
Created February 28, 2015 12:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emaasit/b3a47265f1b810e295e2 to your computer and use it in GitHub Desktop.
Save Emaasit/b3a47265f1b810e295e2 to your computer and use it in GitHub Desktop.
## Download h2o from CRAN
## When downloading from CRAN, keep in mind that the initial
## download from CRAN contains only the R package
install.packages("h2o")
library(h2o)
localH2O <- h2o.init()
## To import small iris data file from H2O's package
irisPath = system.file("extdata", "iris.csv", package="h2o")
iris.hex = h2o.importFile(localH2O, path = irisPath, key = "iris.hex")
## To import an entire folder of files as one data object
pathToFolder = "/Users/PATH-TO-FOLDER/airlines/"
airlines.hex = h2o.importFile(localH2O, path = pathToFolder, key = "airlines.hex")
## To import from HDFS
pathToData = "hdfs://PATH-TO-FILE/airlines_all.csv"
airlines.hex = h2o.importFile(localH2O, path = pathToData, key = "airlines.hex")
## To run a GENERALIZED LINEAR MODEL
h2o.glm(y = "dependent_variable", x = c("independent_variable1","independent_variable2",
"independent_variable3","independent_variable4"),
data = dataset.hex, family = "binomial", nfolds = 10, alpha = 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment