Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## 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