I would like to extract the glmnet generated model coefficients and create a SQL query from them. The function coef(cv.glmnet.fit)
yields a \'dgCMa
There is an approach with using coef() to glmnet() object (your model). In a case below index [[1]] indicate the number of outcome class in multinomial logistic regression, maybe for other models you shoould remove it.
coef_names_GLMnet <- coef(GLMnet, s = 0)[[1]]
row.names(coef_names_GLMnet)[coef_names_GLMnet@i+1]
row.names() indexes in such case needs incrementing (+1) because numeration of variables (data features) in coef() object begining from 0, but after transformation character vector numeration begining from 1.