问题
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 linear model, I cannot find the coefficients of Lasso regression model from summary(lasso). How should I do that? Or maybe I can use glmnet?
来源:https://stackoverflow.com/questions/41797792/how-should-i-get-the-coefficients-of-lasso-model