From 91bf248ff66b36bee70e20b26252001c1569ef5d Mon Sep 17 00:00:00 2001 From: laresbernardo Date: Tue, 4 Jun 2024 15:32:27 +0200 Subject: [PATCH] docs: unite h2o_predict_* --- R/model_predict.R | 20 +++++----- man/ROC.Rd | 3 -- man/conf_mat.Rd | 3 -- man/export_results.Rd | 3 -- man/gain_lift.Rd | 3 -- man/h2o_automl.Rd | 3 -- man/h2o_predict.Rd | 75 ++++++++++++++++++++++++++++++++++++++ man/h2o_predict_API.Rd | 46 ----------------------- man/h2o_predict_MOJO.Rd | 52 -------------------------- man/h2o_predict_binary.Rd | 50 ------------------------- man/h2o_predict_model.Rd | 44 ---------------------- man/h2o_selectmodel.Rd | 3 -- man/impute.Rd | 3 -- man/iter_seeds.Rd | 3 -- man/lasso_vars.Rd | 3 -- man/model_metrics.Rd | 3 -- man/model_preprocess.Rd | 3 -- man/msplit.Rd | 3 -- man/robyn_modelselector.Rd | 2 +- man/stocks_report.Rd | 2 +- 20 files changed, 86 insertions(+), 241 deletions(-) create mode 100644 man/h2o_predict.Rd delete mode 100644 man/h2o_predict_API.Rd delete mode 100644 man/h2o_predict_MOJO.Rd delete mode 100644 man/h2o_predict_binary.Rd delete mode 100644 man/h2o_predict_model.Rd diff --git a/R/model_predict.R b/R/model_predict.R index 24893af81..a971ccdf6 100644 --- a/R/model_predict.R +++ b/R/model_predict.R @@ -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() #' @@ -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)) @@ -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)) @@ -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))) } @@ -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 %>% diff --git a/man/ROC.Rd b/man/ROC.Rd index ee9ebdcd9..5dfd7fd6b 100644 --- a/man/ROC.Rd +++ b/man/ROC.Rd @@ -46,10 +46,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/conf_mat.Rd b/man/conf_mat.Rd index 2459dbaf6..0ec058158 100644 --- a/man/conf_mat.Rd +++ b/man/conf_mat.Rd @@ -52,10 +52,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/export_results.Rd b/man/export_results.Rd index 1a4f24d49..68d1f4680 100644 --- a/man/export_results.Rd +++ b/man/export_results.Rd @@ -48,10 +48,7 @@ Other Machine Learning: \code{\link{conf_mat}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/gain_lift.Rd b/man/gain_lift.Rd index 4c0c163f7..457c35ff2 100644 --- a/man/gain_lift.Rd +++ b/man/gain_lift.Rd @@ -51,10 +51,7 @@ Other Machine Learning: \code{\link{conf_mat}()}, \code{\link{export_results}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/h2o_automl.Rd b/man/h2o_automl.Rd index 5ec2c68b0..c7f910c4a 100644 --- a/man/h2o_automl.Rd +++ b/man/h2o_automl.Rd @@ -201,10 +201,7 @@ Other Machine Learning: \code{\link{conf_mat}()}, \code{\link{export_results}()}, \code{\link{gain_lift}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/h2o_predict.Rd b/man/h2o_predict.Rd new file mode 100644 index 000000000..03306ce0d --- /dev/null +++ b/man/h2o_predict.Rd @@ -0,0 +1,75 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/model_predict.R +\name{h2o_predict_MOJO} +\alias{h2o_predict_MOJO} +\alias{h2o_predict_binary} +\alias{h2o_predict_model} +\alias{h2o_predict_API} +\title{Calculate predictions of h2o Models} +\usage{ +h2o_predict_MOJO(df, model_path, method = "mojo", batch = 300) + +h2o_predict_binary(df, model_path, sample = NA) + +h2o_predict_model(df, model) + +h2o_predict_API(df, api, exclude = "tag") +} +\arguments{ +\item{df}{Dataframe/Vector. Data to insert into the model.} + +\item{model_path}{Character. Relative model path directory or zip file.} + +\item{method}{Character. One of "mojo" or "json".} + +\item{batch}{Integer. Run n batches at a time for "json" method.} + +\item{sample}{Integer. How many rows should the function predict?} + +\item{model}{h2o model Object} + +\item{api}{Character. API URL.} + +\item{exclude}{Character. Name of the variables to exclude.} +} +\value{ +data.frame with predicted results. + +vector with predicted results. + +data.frame with predicted results. + +vector with predicted results. +} +\description{ +\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() + +\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. + +\code{h2o_predict_model} lets the user get scores from a H2O Model Object. + +\code{h2o_predict_API} lets the user get the score from an API service +} +\seealso{ +Other Machine Learning: +\code{\link{ROC}()}, +\code{\link{conf_mat}()}, +\code{\link{export_results}()}, +\code{\link{gain_lift}()}, +\code{\link{h2o_automl}()}, +\code{\link{h2o_selectmodel}()}, +\code{\link{impute}()}, +\code{\link{iter_seeds}()}, +\code{\link{lasso_vars}()}, +\code{\link{model_metrics}()}, +\code{\link{model_preprocess}()}, +\code{\link{msplit}()} +} +\concept{H2O} +\concept{Machine Learning} diff --git a/man/h2o_predict_API.Rd b/man/h2o_predict_API.Rd deleted file mode 100644 index 808c4ac10..000000000 --- a/man/h2o_predict_API.Rd +++ /dev/null @@ -1,46 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/model_predict.R -\name{h2o_predict_API} -\alias{h2o_predict_API} -\title{H2O Predict using API Service} -\usage{ -h2o_predict_API(df, api, exclude = "tag") -} -\arguments{ -\item{df}{Dataframe/Vector. Data to insert into the model.} - -\item{api}{Character. API URL.} - -\item{exclude}{Character. Name of the variables to exclude.} -} -\value{ -vector with predicted results. -} -\description{ -This function lets the user get the score from an API service -} -\seealso{ -Other Machine Learning: -\code{\link{ROC}()}, -\code{\link{conf_mat}()}, -\code{\link{export_results}()}, -\code{\link{gain_lift}()}, -\code{\link{h2o_automl}()}, -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, -\code{\link{h2o_selectmodel}()}, -\code{\link{impute}()}, -\code{\link{iter_seeds}()}, -\code{\link{lasso_vars}()}, -\code{\link{model_metrics}()}, -\code{\link{model_preprocess}()}, -\code{\link{msplit}()} - -Other H2O: -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()} -} -\concept{H2O} -\concept{Machine Learning} diff --git a/man/h2o_predict_MOJO.Rd b/man/h2o_predict_MOJO.Rd deleted file mode 100644 index 0908dab69..000000000 --- a/man/h2o_predict_MOJO.Rd +++ /dev/null @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/model_predict.R -\name{h2o_predict_MOJO} -\alias{h2o_predict_MOJO} -\title{H2O Predict using MOJO file} -\usage{ -h2o_predict_MOJO(df, model_path, method = "mojo", batch = 300) -} -\arguments{ -\item{df}{Dataframe. Data to pass to the model.} - -\item{model_path}{Character. Relative path of directory -where your zip model file is. If multiple zip files are found, -first one found will be used.} - -\item{method}{Character. One of "mojo" or "json".} - -\item{batch}{Integer. Run n batches at a time for "json" method.} -} -\value{ -data.frame with predicted results. -} -\description{ -This function 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() -} -\seealso{ -Other Machine Learning: -\code{\link{ROC}()}, -\code{\link{conf_mat}()}, -\code{\link{export_results}()}, -\code{\link{gain_lift}()}, -\code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, -\code{\link{h2o_selectmodel}()}, -\code{\link{impute}()}, -\code{\link{iter_seeds}()}, -\code{\link{lasso_vars}()}, -\code{\link{model_metrics}()}, -\code{\link{model_preprocess}()}, -\code{\link{msplit}()} - -Other H2O: -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()} -} -\concept{H2O} -\concept{Machine Learning} diff --git a/man/h2o_predict_binary.Rd b/man/h2o_predict_binary.Rd deleted file mode 100644 index 8baa4f9e0..000000000 --- a/man/h2o_predict_binary.Rd +++ /dev/null @@ -1,50 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/model_predict.R -\name{h2o_predict_binary} -\alias{h2o_predict_binary} -\title{H2O Predict using Binary file} -\usage{ -h2o_predict_binary(df, model_path, sample = NA) -} -\arguments{ -\item{df}{Dataframe. Data to insert into the model.} - -\item{model_path}{Character. Relative model path directory or zip file.} - -\item{sample}{Integer. How many rows should the function predict?} -} -\value{ -vector with predicted results. -} -\description{ -This function 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. -} -\seealso{ -Other Machine Learning: -\code{\link{ROC}()}, -\code{\link{conf_mat}()}, -\code{\link{export_results}()}, -\code{\link{gain_lift}()}, -\code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_model}()}, -\code{\link{h2o_selectmodel}()}, -\code{\link{impute}()}, -\code{\link{iter_seeds}()}, -\code{\link{lasso_vars}()}, -\code{\link{model_metrics}()}, -\code{\link{model_preprocess}()}, -\code{\link{msplit}()} - -Other H2O: -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_model}()} -} -\concept{H2O} -\concept{Machine Learning} diff --git a/man/h2o_predict_model.Rd b/man/h2o_predict_model.Rd deleted file mode 100644 index 7296ede14..000000000 --- a/man/h2o_predict_model.Rd +++ /dev/null @@ -1,44 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/model_predict.R -\name{h2o_predict_model} -\alias{h2o_predict_model} -\title{H2O Predict using H2O Model Object} -\usage{ -h2o_predict_model(df, model) -} -\arguments{ -\item{df}{Dataframe/Vector. Data to insert into the model.} - -\item{model}{h2o model Object} -} -\value{ -data.frame with predicted results. -} -\description{ -This function lets the user get scores from a H2O Model Object. -} -\seealso{ -Other Machine Learning: -\code{\link{ROC}()}, -\code{\link{conf_mat}()}, -\code{\link{export_results}()}, -\code{\link{gain_lift}()}, -\code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_selectmodel}()}, -\code{\link{impute}()}, -\code{\link{iter_seeds}()}, -\code{\link{lasso_vars}()}, -\code{\link{model_metrics}()}, -\code{\link{model_preprocess}()}, -\code{\link{msplit}()} - -Other H2O: -\code{\link{h2o_predict_API}()}, -\code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()} -} -\concept{H2O} -\concept{Machine Learning} diff --git a/man/h2o_selectmodel.Rd b/man/h2o_selectmodel.Rd index b227e314e..ed7e629dd 100644 --- a/man/h2o_selectmodel.Rd +++ b/man/h2o_selectmodel.Rd @@ -28,10 +28,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, \code{\link{lasso_vars}()}, diff --git a/man/impute.Rd b/man/impute.Rd index 393c0bef1..addb6e10e 100644 --- a/man/impute.Rd +++ b/man/impute.Rd @@ -54,10 +54,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{iter_seeds}()}, \code{\link{lasso_vars}()}, diff --git a/man/iter_seeds.Rd b/man/iter_seeds.Rd index 9feed976d..d8aab1628 100644 --- a/man/iter_seeds.Rd +++ b/man/iter_seeds.Rd @@ -31,10 +31,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{lasso_vars}()}, diff --git a/man/lasso_vars.Rd b/man/lasso_vars.Rd index 517a48eb0..61a8ccb3f 100644 --- a/man/lasso_vars.Rd +++ b/man/lasso_vars.Rd @@ -66,10 +66,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/model_metrics.Rd b/man/model_metrics.Rd index cf52a7da7..725e79819 100644 --- a/man/model_metrics.Rd +++ b/man/model_metrics.Rd @@ -99,10 +99,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/model_preprocess.Rd b/man/model_preprocess.Rd index 1a79ee2af..0dfe00f1a 100644 --- a/man/model_preprocess.Rd +++ b/man/model_preprocess.Rd @@ -104,10 +104,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/msplit.Rd b/man/msplit.Rd index dfe84b521..6442b8d70 100644 --- a/man/msplit.Rd +++ b/man/msplit.Rd @@ -37,10 +37,7 @@ Other Machine Learning: \code{\link{export_results}()}, \code{\link{gain_lift}()}, \code{\link{h2o_automl}()}, -\code{\link{h2o_predict_API}()}, \code{\link{h2o_predict_MOJO}()}, -\code{\link{h2o_predict_binary}()}, -\code{\link{h2o_predict_model}()}, \code{\link{h2o_selectmodel}()}, \code{\link{impute}()}, \code{\link{iter_seeds}()}, diff --git a/man/robyn_modelselector.Rd b/man/robyn_modelselector.Rd index e49704635..8e9739d74 100644 --- a/man/robyn_modelselector.Rd +++ b/man/robyn_modelselector.Rd @@ -71,7 +71,7 @@ several criteria/metrics such as potential improvement on budget allocator, how many non-zero coefficients there are, R squared, historical performance, baseline expectation, etc. -Read more about this functionality in Medium post: +Read more about this functionality in Medium post: \href{https://bit.ly/mmm-candidates}{here}. } \seealso{ diff --git a/man/stocks_report.Rd b/man/stocks_report.Rd index 418c2d444..50b3e8786 100644 --- a/man/stocks_report.Rd +++ b/man/stocks_report.Rd @@ -6,7 +6,7 @@ \alias{daily_portfolio} \alias{stocks_obj} \alias{stocks_report} -\title{Create a Personal Investing Portfolio Report} +\title{Build a Personal Investing Portfolio Report} \usage{ stocks_file( file = NA,