Skip to content

Instantly share code, notes, and snippets.

@JohnMount
Forked from edgararuiz-zz/h2o.R
Last active January 24, 2017 16:59
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 JohnMount/bdfb47c2d02f96a4a36017c7e5ce2de6 to your computer and use it in GitHub Desktop.
Save JohnMount/bdfb47c2d02f96a4a36017c7e5ce2de6 to your computer and use it in GitHub Desktop.
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type = "source", repos = "http://h2o-release.s3.amazonaws.com/h2o/rel-turing/7/R")
install.packages("sparklyr")
library(devtools)
devtools::install_github("h2oai/rsparkling", ref = "stable")
library(sparklyr)
spark_install(version = "2.0.0")
options(rsparkling.sparklingwater.version = "2.0.0") # Using Sparkling Water 2.0.0
library(rsparkling)
sc <- spark_connect(master = "local", version = "2.0.0")
h2o_context(sc)
library(dplyr)
mtcars_tbl <- copy_to(sc, mtcars, overwrite = TRUE)
mtcars_tbl
# transform our data set, and then partition into 'training', 'test'
partitions <- mtcars_tbl %>%
filter(hp >= 100) %>%
mutate(cyl8 = cyl == 8) %>%
sdf_partition(training = 0.5, test = 0.5, seed = 1099)
library('h2o')
h2ohandle <- h2o.init()
training <- as_h2o_frame(sc, partitions$training)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment