Skip to content

Commit

Permalink
Merge pull request #506 from h2oai/cran-submission
Browse files Browse the repository at this point in the history
CRAN submission minor fixes/updates
  • Loading branch information
terrytangyuan committed Mar 26, 2018
2 parents 3fa2b8f + 12e0313 commit 99df2a6
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/interface_r/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Package: h2o4gpu
Type: Package
Title: R Interface to 'H2O4GPU'
Title: Interface to 'H2O4GPU'
Version: 0.2.0
Authors@R: c(
person("Yuan", "Tang", role = c("aut", "cre"), email = "terry@h2o.ai"),
person("Yuan", "Tang", role = c("aut", "cre"),
email = "terrytangyuan@gmail.com",
comment = c(ORCID = "0000-0001-5243-233X")),
person("Navdeep", "Gill", role = c("aut"), email = "navdeep@h2o.ai"),
person("Erin", "LeDell", role = c("aut"), email = "erin@h2o.ai"),
person("H2O.ai", role = c("cph", "fnd")))
Description: R Interface to 'H2O4GPU' - A collection of 'GPU' solvers for machine learning algorithms.
Description: Interface to 'H2O4GPU' <https://github.com/h2oai/h2o4gpu>, a collection of 'GPU' solvers for machine learning algorithms.
License: Apache License 2.0
URL: https://github.com/h2oai/h2o4gpu
BugReports: https://github.com/h2oai/h2o4gpu/issues
SystemRequirements: Python (>= 3.6) with header files and shared library;
h2o4gpu (https://github.com/h2oai/h2o4gpu)
H2O4GPU (https://github.com/h2oai/h2o4gpu)
Encoding: UTF-8
LazyData: true
Depends:
Expand Down
2 changes: 1 addition & 1 deletion src/interface_r/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## h2o4gpu 0.0.1 (CRAN)
## h2o4gpu 0.2.0 (CRAN)

* Initial release.
50 changes: 50 additions & 0 deletions src/interface_r/R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ print.h2o4gpu_model <- function(x, ...) {
#' @param ... Additional arguments (unused for now).
#'
#' @export
#' @examples
#' \dontrun{
#'
#' library(h2o4gpu)
#'
#' # Setup dataset
#' x <- iris[1:4]
#' y <- as.integer(iris$Species) - 1
#'
#' # Train the classifier
#' h2o4gpu.random_forest_classifier() %>% fit(x, y)
#' }
fit.h2o4gpu_model <- function(object, x, y = NULL, ...) {
if (inherits(object$model, "h2o4gpu.solvers.elastic_net.ElasticNet") && object$params$family == "logistic"){
if (length(unique(y)) > 2){
Expand All @@ -94,6 +106,23 @@ fit.h2o4gpu_model <- function(object, x, y = NULL, ...) {
#' @param type One of "raw" or "prob", indicating the type of output: predicted values or probabilities
#' @param ... Additional arguments (unused for now).
#' @export
#' @examples
#' \dontrun{
#'
#' library(h2o4gpu)
#'
#' # Setup dataset
#' x <- iris[1:4]
#' y <- as.integer(iris$Species) - 1
#'
#' # Initialize and train the classifier
#' model <- h2o4gpu.random_forest_classifier() %>% fit(x, y)
#'
#' # Make predictions
#' predictions <- model %>% predict(x)
#'
#' }
#'
predict.h2o4gpu_model <- function(object, x, type="raw", ...) {
if (type == "raw") {
preds <- object$model$predict(X = resolve_model_input(x), ...)
Expand Down Expand Up @@ -122,6 +151,27 @@ predict.h2o4gpu_model <- function(object, x, type="raw", ...) {
#' be used in generating predictions.
#' @param ... Additional arguments (unused for now).
#' @export
#' @examples
#' \dontrun{
#'
#' library(h2o4gpu)
#'
#' # Prepare data
#' iris$Species <- as.integer(iris$Species) # convert to numeric data
#'
#' # Randomly sample 80% of the rows for the training set
#' set.seed(1)
#' train_idx <- sample(1:nrow(iris), 0.8*nrow(iris))
#' train <- iris[train_idx, ]
#' test <- iris[-train_idx, ]
#'
#' # Train a K-Means model
#' model_km <- h2o4gpu.kmeans(n_clusters = 3L) %>% fit(train)
#'
#' # Transform test data
#' test_dist <- model_km %>% transform(test)
#'
#' }
transform.h2o4gpu_model <- function(object, x, ...) {
object$model$transform(X = resolve_model_input(x), ...)
}
17 changes: 17 additions & 0 deletions src/interface_r/R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
#'
#' @docType package
#' @name h2o4gpu
#'
#' @examples
#' \dontrun{
#'
#' library(h2o4gpu)
#'
#' # Setup dataset
#' x <- iris[1:4]
#' y <- as.integer(iris$Species) - 1
#'
#' # Initialize and train the classifier
#' model <- h2o4gpu.random_forest_classifier() %>% fit(x, y)
#'
#' # Make predictions
#' predictions <- model %>% predict(x)
#'
#' }
NULL

h2o4gpu <- NULL
Expand Down
11 changes: 2 additions & 9 deletions src/interface_r/cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@

0 errors | 0 warnings | 1 note

New submission

* This is a new release.

## Reverse dependencies

This is a new release, so there are no reverse dependencies.

---

* I have run R CMD check on the NUMBER downstream dependencies.
(Summary at ...).

* FAILURE SUMMARY

* All revdep maintainers were notified of the release on RELEASE DATE.
13 changes: 13 additions & 0 deletions src/interface_r/man/fit.h2o4gpu_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/interface_r/man/h2o4gpu.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/interface_r/man/predict.h2o4gpu_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/interface_r/man/transform.h2o4gpu_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/interface_r/vignettes/getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: "Navdeep Gill, Erin LeDell, Yuan Tang"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteIndexEntry{H2O4GPU: Machine Learning with GPUs in R}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -74,7 +74,7 @@ ce(actual = y, predicted = pred)

The tree based models (Random Forest and GBM) are built on top of the very powerful [XGBoost](https://xgboost.readthedocs.io/en/latest/) library, and the Elastic Net GLM has been built upon the POGS solver. [Proximal Graph Solver (POGS)](http://stanford.edu/%7Eboyd/papers/pogs.html) is a solver for convex optimization problems in graph form using Alternating Direction Method of Multipliers (ADMM). We have found that this method is not as fast as we'd like it to be, so we are working on implementing an entirely new GLM from scratch (follow progress [here](https://github.com/h2oai/h2o4gpu/issues/356)).

The **h2o4gpu** R package does not include a suite of internal model metrics functions, therefore we encourage users to use a third-party model metrics package of their choice. For all the examples below, we will use the [Metrics](https://cran.r-project.org/web/packages/Metrics/index.html) R package. This package has a large number of model metrics functions, all with a very simple, unified API.
The **h2o4gpu** R package does not include a suite of internal model metrics functions, therefore we encourage users to use a third-party model metrics package of their choice. For all the examples below, we will use the [Metrics](https://CRAN.R-project.org/package=Metrics) R package. This package has a large number of model metrics functions, all with a very simple, unified API.

### Binary Classification

Expand Down

0 comments on commit 99df2a6

Please sign in to comment.