Nothing
#' Flexible discriminant analysis
#'
#' @description
#'
#' `discrim_flexible()` defines a model that fits a discriminant analysis model
#' that can use nonlinear features created using multivariate adaptive
#' regression splines (MARS). This function can fit classification models.
#'
#' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("discrim_flexible")}
#'
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams discrim_linear
#' @param num_terms The number of features that will be retained in the
#' final model, including the intercept.
#' @param prod_degree The highest possible interaction degree.
#' @param prune_method The pruning method.
#'
#' @templateVar modeltype discrim_flexible
#' @template spec-details
#'
#' @template spec-references
#'
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("discrim_flexible")}
#'
#' @export
discrim_flexible <-
function(mode = "classification", num_terms = NULL, prod_degree = NULL,
prune_method = NULL, engine = "earth") {
args <- list(
num_terms = enquo(num_terms),
prod_degree = enquo(prod_degree),
prune_method = enquo(prune_method)
)
new_model_spec(
"discrim_flexible",
args = args,
eng_args = NULL,
mode = mode,
user_specified_mode = !missing(mode),
method = NULL,
engine = engine,
user_specified_engine = !missing(engine)
)
}
# ------------------------------------------------------------------------------
#' Update a model specification
#' @param object A model specification.
#' @param ... Not used for `update()`.
#' @param fresh A logical for whether the arguments should be
#' modified in-place of or replaced wholesale.
#' @method update discrim_flexible
#' @rdname parsnip_update
#' @inheritParams discrim_flexible
#' @export
update.discrim_flexible <-
function(object,
num_terms = NULL,
prod_degree = NULL,
prune_method = NULL,
fresh = FALSE, ...) {
args <- list(
num_terms = enquo(num_terms),
prod_degree = enquo(prod_degree),
prune_method = enquo(prune_method)
)
update_spec(
object = object,
parameters = NULL,
args_enquo_list = args,
fresh = fresh,
cls = "discrim_flexible",
...
)
}
# ------------------------------------------------------------------------------
check_args.discrim_flexible <- function(object) {
args <- lapply(object$args, rlang::eval_tidy)
if (is.numeric(args$prod_degree) && args$prod_degree < 0)
stop("`prod_degree` should be >= 1", call. = FALSE)
if (is.numeric(args$num_terms) && args$num_terms < 0)
stop("`num_terms` should be >= 1", call. = FALSE)
if (!is.character(args$prune_method) &&
!is.null(args$prune_method) &&
!is.character(args$prune_method))
stop("`prune_method` should be a single string value", call. = FALSE)
invisible(object)
}
# ------------------------------------------------------------------------------
set_new_model("discrim_flexible")
set_model_mode("discrim_flexible", "classification")
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.