Here is my code:
library(MASS)
library(caret)
df <- Boston
set.seed(3721)
cv.10.folds <- createFolds(df$medv, k = 10)
lasso_grid <- expand.grid(fraction=c(1,0.1,0.01,0.001))
lasso <- train(medv ~ .,
data = df,
preProcess = c("center", "scale"),
method ='lasso',
tuneGrid = lasso_grid,
trControl= trainControl(method = "cv",
number = 10,
index = cv.10.folds))
lasso
Unlike the linear model, I cannot find the coefficients of the Lasso regression model from the resume (lasso). How should I do it? Or maybe I can use glmnet?
source
share