parsnip (version 0.0.0.9001)

logistic_reg: General Interface for Logistic Regression Models

Description

logistic_reg is a way to generate a specification of a model before fitting and allows the model to be created using different packages in R, Stan, or via Spark. The main arguments for the model are:

  • regularization: The total amount of regularization in the model. Note that this must be zero for some engines.

  • mixture: The proportion of L2 regularization in the model. Note that this will be ignored for some engines.

These arguments are converted to their specific names at the time that the model is fit. Other options and argument can be set using the others argument. If left to their defaults here (NULL), the values are taken from the underlying model functions.

If parameters need to be modified, this function can be used in lieu of recreating the object from scratch.

Usage

logistic_reg(mode = "classification", regularization = NULL,
  mixture = NULL, others = list(), ...)

# S3 method for logistic_reg update(object, regularization = NULL, mixture = NULL, others = list(), fresh = FALSE, ...)

Arguments

mode

A single character string for the type of model. The only possible value for this model is "classification".

regularization

An non-negative number representing the total amount of regularization.

mixture

A number between zero and one (inclusive) that represents the proportion of regularization that is used for the L2 penalty (i.e. weight decay, or ridge regression) versus L1 (the lasso).

others

A named list of arguments to be used by the underlying models (e.g., stats::glm, rstanarm::stan_glm, etc.). These are not evaluated until the model is fit and will be substituted into the model fit expression.

...

Used for S3 method consistency. Any arguments passed to the ellipses will result in an error. Use others instead.

object

A logistic regression model specification.

fresh

A logical for whether the arguments should be modified in-place of or replaced wholesale.

Value

An updated model specification.

Details

The data given to the function are not saved and are only used to determine the mode of the model. For logistic_reg,the mode will always be "classification".

The model can be created using the fit() function using the following engines:

  • R: "glm" or "glmnet"

  • Stan: "stan"

  • Spark: "spark"

See Also

varying(), fit()

Examples

Run this code
# NOT RUN {
logistic_reg()
# Parameters can be represented by a placeholder:
logistic_reg(regularization = varying())
model <- logistic_reg(regularization = 10, mixture = 0.1)
model
update(model, regularization = 1)
update(model, regularization = 1, fresh = TRUE)
# }

Run the code above in your browser using DataCamp Workspace