Nothing
# This file is auto-generated by h2o-3/h2o-bindings/bin/gen_R.py
# Copyright 2016 H2O.ai; Apache License Version 2.0 (see LICENSE for details)
#'
# -------------------------- isotonicregression -------------------------- #
#'
#' Build an Isotonic Regression model
#'
#' Builds an Isotonic Regression model on an H2OFrame with a single feature (univariate regression).
#'
#' @param x (Optional) A vector containing the names or indices of the predictor variables to use in building the model.
#' If x is missing, then all columns except y are used.
#' @param y The name or column index of the response variable in the data.
#' The response must be either a numeric or a categorical/factor variable.
#' If the response is numeric, then a regression model will be trained, otherwise it will train a classification model.
#' @param training_frame Id of the training data frame.
#' @param model_id Destination id for this model; auto-generated if not specified.
#' @param validation_frame Id of the validation data frame.
#' @param weights_column Column with observation weights. Giving some observation a weight of zero is equivalent to excluding it from
#' the dataset; giving an observation a relative weight of 2 is equivalent to repeating that row twice. Negative
#' weights are not allowed. Note: Weights are per-row observation weights and do not increase the size of the
#' data frame. This is typically the number of times a row is repeated, but non-integer values are supported as
#' well. During training, rows with higher weights matter more, due to the larger loss function pre-factor. If
#' you set weight = 0 for a row, the returned prediction frame at that row is zero and this is incorrect. To get
#' an accurate prediction, remove all rows with weight == 0.
#' @param out_of_bounds Method of handling values of X predictor that are outside of the bounds seen in training. Must be one of:
#' "NA", "clip". Defaults to NA.
#' @param custom_metric_func Reference to custom evaluation function, format: `language:keyName=funcName`
#' @param nfolds Number of folds for K-fold cross-validation (0 to disable or >= 2). Defaults to 0.
#' @param keep_cross_validation_models \code{Logical}. Whether to keep the cross-validation models. Defaults to TRUE.
#' @param keep_cross_validation_predictions \code{Logical}. Whether to keep the predictions of the cross-validation models. Defaults to FALSE.
#' @param keep_cross_validation_fold_assignment \code{Logical}. Whether to keep the cross-validation fold assignment. Defaults to FALSE.
#' @param fold_assignment Cross-validation fold assignment scheme, if fold_column is not specified. The 'Stratified' option will
#' stratify the folds based on the response variable, for classification problems. Must be one of: "AUTO",
#' "Random", "Modulo", "Stratified". Defaults to AUTO.
#' @param fold_column Column with cross-validation fold index assignment per observation.
#' @return Creates a \linkS4class{H2OModel} object of the right type.
#' @seealso \code{\link{predict.H2OModel}} for prediction
#' @examples
#' \dontrun{
#' library(h2o)
#' h2o.init()
#'
#' N <- 100
#' x <- seq(N)
#' y <- sample(-50:50, N, replace=TRUE) + 50 * log1p(x)
#'
#' train <- as.h2o(data.frame(x = x, y = y))
#' isotonic <- h2o.isotonicregression(x = "x", y = "y", training_frame = train)
#' }
#' @export
h2o.isotonicregression <- function(x,
y,
training_frame,
model_id = NULL,
validation_frame = NULL,
weights_column = NULL,
out_of_bounds = c("NA", "clip"),
custom_metric_func = NULL,
nfolds = 0,
keep_cross_validation_models = TRUE,
keep_cross_validation_predictions = FALSE,
keep_cross_validation_fold_assignment = FALSE,
fold_assignment = c("AUTO", "Random", "Modulo", "Stratified"),
fold_column = NULL)
{
# Validate required training_frame first and other frame args: should be a valid key or an H2OFrame object
training_frame <- .validate.H2OFrame(training_frame, required=TRUE)
validation_frame <- .validate.H2OFrame(validation_frame, required=FALSE)
# Validate other required args
# If x is missing, then assume user wants to use all columns as features.
if (missing(x)) {
if (is.numeric(y)) {
x <- setdiff(col(training_frame), y)
} else {
x <- setdiff(colnames(training_frame), y)
}
}
# Build parameter list to send to model builder
parms <- list()
parms$training_frame <- training_frame
args <- .verify_dataxy(training_frame, x, y)
if( !missing(weights_column) && !is.null(weights_column)) args$x_ignore <- args$x_ignore[!( weights_column == args$x_ignore )]
parms$ignored_columns <- args$x_ignore
parms$response_column <- args$y
if (!missing(model_id))
parms$model_id <- model_id
if (!missing(validation_frame))
parms$validation_frame <- validation_frame
if (!missing(weights_column))
parms$weights_column <- weights_column
if (!missing(out_of_bounds))
parms$out_of_bounds <- out_of_bounds
if (!missing(custom_metric_func))
parms$custom_metric_func <- custom_metric_func
if (!missing(nfolds))
parms$nfolds <- nfolds
if (!missing(keep_cross_validation_models))
parms$keep_cross_validation_models <- keep_cross_validation_models
if (!missing(keep_cross_validation_predictions))
parms$keep_cross_validation_predictions <- keep_cross_validation_predictions
if (!missing(keep_cross_validation_fold_assignment))
parms$keep_cross_validation_fold_assignment <- keep_cross_validation_fold_assignment
if (!missing(fold_assignment))
parms$fold_assignment <- fold_assignment
if (!missing(fold_column))
parms$fold_column <- fold_column
# Error check and build model
model <- .h2o.modelJob('isotonicregression', parms, h2oRestApiVersion=3, verbose=FALSE)
return(model)
}
.h2o.train_segments_isotonicregression <- function(x,
y,
training_frame,
validation_frame = NULL,
weights_column = NULL,
out_of_bounds = c("NA", "clip"),
custom_metric_func = NULL,
nfolds = 0,
keep_cross_validation_models = TRUE,
keep_cross_validation_predictions = FALSE,
keep_cross_validation_fold_assignment = FALSE,
fold_assignment = c("AUTO", "Random", "Modulo", "Stratified"),
fold_column = NULL,
segment_columns = NULL,
segment_models_id = NULL,
parallelism = 1)
{
# formally define variables that were excluded from function parameters
model_id <- NULL
verbose <- NULL
destination_key <- NULL
# Validate required training_frame first and other frame args: should be a valid key or an H2OFrame object
training_frame <- .validate.H2OFrame(training_frame, required=TRUE)
validation_frame <- .validate.H2OFrame(validation_frame, required=FALSE)
# Validate other required args
# If x is missing, then assume user wants to use all columns as features.
if (missing(x)) {
if (is.numeric(y)) {
x <- setdiff(col(training_frame), y)
} else {
x <- setdiff(colnames(training_frame), y)
}
}
# Build parameter list to send to model builder
parms <- list()
parms$training_frame <- training_frame
args <- .verify_dataxy(training_frame, x, y)
if( !missing(weights_column) && !is.null(weights_column)) args$x_ignore <- args$x_ignore[!( weights_column == args$x_ignore )]
parms$ignored_columns <- args$x_ignore
parms$response_column <- args$y
if (!missing(validation_frame))
parms$validation_frame <- validation_frame
if (!missing(weights_column))
parms$weights_column <- weights_column
if (!missing(out_of_bounds))
parms$out_of_bounds <- out_of_bounds
if (!missing(custom_metric_func))
parms$custom_metric_func <- custom_metric_func
if (!missing(nfolds))
parms$nfolds <- nfolds
if (!missing(keep_cross_validation_models))
parms$keep_cross_validation_models <- keep_cross_validation_models
if (!missing(keep_cross_validation_predictions))
parms$keep_cross_validation_predictions <- keep_cross_validation_predictions
if (!missing(keep_cross_validation_fold_assignment))
parms$keep_cross_validation_fold_assignment <- keep_cross_validation_fold_assignment
if (!missing(fold_assignment))
parms$fold_assignment <- fold_assignment
if (!missing(fold_column))
parms$fold_column <- fold_column
# Build segment-models specific parameters
segment_parms <- list()
if (!missing(segment_columns))
segment_parms$segment_columns <- segment_columns
if (!missing(segment_models_id))
segment_parms$segment_models_id <- segment_models_id
segment_parms$parallelism <- parallelism
# Error check and build segment models
segment_models <- .h2o.segmentModelsJob('isotonicregression', segment_parms, parms, h2oRestApiVersion=3)
return(segment_models)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.