Skip to content

Commit

Permalink
docs: unite h2o_predict_*
Browse files Browse the repository at this point in the history
  • Loading branch information
laresbernardo committed Jun 4, 2024
1 parent c64870d commit 91bf248
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 241 deletions.
20 changes: 9 additions & 11 deletions R/model_predict.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
####################################################################
#' H2O Predict using MOJO file
#' Calculate predictions of h2o Models
#'
#' This function lets the user predict using the h2o .zip file
#' \code{h2o_predict_MOJO} lets the user predict using the h2o .zip file
#' containing the MOJO files. Note that it works with the files
#' generated when using the function export_results()
#'
Expand All @@ -15,6 +15,7 @@
#' @param batch Integer. Run n batches at a time for "json" method.
#' @return data.frame with predicted results.
#' @export
#' @rdname h2o_predict
h2o_predict_MOJO <- function(df, model_path, method = "mojo", batch = 300) {
quiet(h2o.init(nthreads = -1, port = 54321))

Expand Down Expand Up @@ -67,19 +68,18 @@ h2o_predict_MOJO <- function(df, model_path, method = "mojo", batch = 300) {
####################################################################
#' H2O Predict using Binary file
#'
#' This function lets the user predict using the h2o binary file.
#' \code{h2o_predict_binary} lets the user predict using the h2o binary file.
#' Note that it works with the files generated when using the
#' function export_results(). Recommendation: use the
#' h2o_predict_MOJO() function when possible - it let's you change
#' h2o's version without problem.
#'
#' @family Machine Learning
#' @family H2O
#' @param df Dataframe. Data to insert into the model.
#' @param model_path Character. Relative model path directory or zip file.
#' @param sample Integer. How many rows should the function predict?
#' @return vector with predicted results.
#' @export
#' @rdname h2o_predict
h2o_predict_binary <- function(df, model_path, sample = NA) {
message("Use of h2o_predict_MOJO instead highly recommended!")
quiet(h2o.init(nthreads = -1, port = 54321))
Expand All @@ -102,14 +102,13 @@ h2o_predict_binary <- function(df, model_path, sample = NA) {
####################################################################
#' H2O Predict using H2O Model Object
#'
#' This function lets the user get scores from a H2O Model Object.
#' \code{h2o_predict_model} lets the user get scores from a H2O Model Object.
#'
#' @family Machine Learning
#' @family H2O
#' @param df Dataframe/Vector. Data to insert into the model.
#' @param model h2o model Object
#' @return data.frame with predicted results.
#' @export
#' @rdname h2o_predict
h2o_predict_model <- function(df, model) {
as.data.frame(predict(model, as.h2o(df)))
}
Expand All @@ -118,15 +117,14 @@ h2o_predict_model <- function(df, model) {
####################################################################
#' H2O Predict using API Service
#'
#' This function lets the user get the score from an API service
#' \code{h2o_predict_API} lets the user get the score from an API service
#'
#' @family Machine Learning
#' @family H2O
#' @param df Dataframe/Vector. Data to insert into the model.
#' @param api Character. API URL.
#' @param exclude Character. Name of the variables to exclude.
#' @return vector with predicted results.
#' @export
#' @rdname h2o_predict
h2o_predict_API <- function(df, api, exclude = "tag") {
post <- function(df, api) {
df <- df %>%
Expand Down
3 changes: 0 additions & 3 deletions man/ROC.Rd

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

3 changes: 0 additions & 3 deletions man/conf_mat.Rd

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

3 changes: 0 additions & 3 deletions man/export_results.Rd

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

3 changes: 0 additions & 3 deletions man/gain_lift.Rd

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

3 changes: 0 additions & 3 deletions man/h2o_automl.Rd

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

75 changes: 75 additions & 0 deletions man/h2o_predict.Rd

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

46 changes: 0 additions & 46 deletions man/h2o_predict_API.Rd

This file was deleted.

52 changes: 0 additions & 52 deletions man/h2o_predict_MOJO.Rd

This file was deleted.

50 changes: 0 additions & 50 deletions man/h2o_predict_binary.Rd

This file was deleted.

Loading

0 comments on commit 91bf248

Please sign in to comment.