| train.glmnet {traineR} | R Documentation |
train.glmnet
Description
Provides a wrapping function for the glmnet.
Usage
train.glmnet(
formula,
data,
standardize = TRUE,
alpha = 1,
family = "multinomial",
cv = TRUE,
...
)
Arguments
formula |
A formula of the form groups ~ x1 + x2 + ... That is, the response is the grouping factor and the right hand side specifies the (non-factor) discriminators. |
data |
An optional data frame, list or environment from which variables specified in formula are preferentially to be taken. |
standardize |
Logical flag for x variable standardization, prior to fitting the model sequence. The coefficients are always returned on the original scale. Default is standardize=TRUE. If variables are in the same units already, you might not wish to standardize. See details below for y standardization with family="gaussian". |
alpha |
The elasticnet mixing parameter. alpha=1 is the lasso penalty, and alpha=0 the ridge penalty. |
family |
Either a character string representing one of the built-in families, or else a glm() family object. For more information, see Details section below or the documentation for response type (above). |
cv |
True or False. Perform cross-validation to find the best value of the penalty parameter lambda and save this value in the model. This value could be used in predict() function. |
... |
Arguments passed to or from other methods. |
Value
A object glmnet.prmdt with additional information to the model that allows to homogenize the results.
Note
The parameter information was taken from the original function glmnet.
See Also
The internal function is from package glmnet.
Examples
# Classification
len <- nrow(iris)
sampl <- sample(x = 1:len,size = len*0.20,replace = FALSE)
ttesting <- iris[sampl,]
ttraining <- iris[-sampl,]
model.glmnet <- train.glmnet(Species~.,ttraining)
prediction <- predict(model.glmnet,ttesting)
prediction
# Regression
len <- nrow(swiss)
sampl <- sample(x = 1:len,size = len*0.20,replace = FALSE)
ttesting <- swiss[sampl,]
ttraining <- swiss[-sampl,]
model.glmnet <- train.glmnet(Infant.Mortality~.,ttraining, family = "gaussian")
prediction <- predict(model.glmnet, ttesting)
prediction