How should I get the coefficients of Lasso Model?

佐手、 提交于 2019-12-24 00:19:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!