glmnet

Caret package - glmnet variable importance

爷,独闯天下 提交于 2020-02-24 11:30:15
问题 I am using the glmnet package to perform a LASSO regression. I am now working on feature importance using the caret package. What I don't understand is the value of the importance. Could anyone enlighten me? Is there any formula to calculate these values or does that mean that these values are based on the beta values? ROC curve variable importance only 7 most important variables shown (out of 25) Importance feature1 0.8974 feature2 0.8962 feature3 0.8957 feature4 0.8744 feature5 0.8701

Ridge regression in glmnet in R; Calculating VIF for different lambda values using glmnet package

匆匆过客 提交于 2020-01-24 13:04:20
问题 I have a set of multicollinear variables and I'm trying to use ridge regression to tackle that. I am using the GLMNET package in R with alpha = 0 (for ridge regression). library(glmnet) I have a sequence of lambda values; and I am choosing the best lambda value through cv.glmnet lambda <- 10^seq(10, -2, length = 100) -- creating model matrix and assigning the y variable x <- model.matrix(dv ~ ., datamatrix) [,-1] y <- datamatrix$dv -- Using cross validation to determine the best lambda and

Ridge regression in glmnet in R; Calculating VIF for different lambda values using glmnet package

心已入冬 提交于 2020-01-24 13:04:04
问题 I have a set of multicollinear variables and I'm trying to use ridge regression to tackle that. I am using the GLMNET package in R with alpha = 0 (for ridge regression). library(glmnet) I have a sequence of lambda values; and I am choosing the best lambda value through cv.glmnet lambda <- 10^seq(10, -2, length = 100) -- creating model matrix and assigning the y variable x <- model.matrix(dv ~ ., datamatrix) [,-1] y <- datamatrix$dv -- Using cross validation to determine the best lambda and

Using glmnet with MATLAB R2016a

倖福魔咒の 提交于 2020-01-17 04:36:20
问题 i'm trying to use glmnet vignette in MATLAB R2016a on windows 10 (64bit). I downloaded the version from here. Every time that I try to use a function (like cvglmnet ) MATLAB crashes. The glmnet version for MATLAB was tested only on MATLAB 2013b (64-bit), but I wanted to know if someone was able to use it on other versions of MATLAB and how to do that. I think the problem is the mex file that maybe should be recompiled since the error on the MATLAB crash says This error was detected while a

glmnet lasso ROC charts

会有一股神秘感。 提交于 2020-01-06 07:34:07
问题 I was using k-fold cross validation in glmnet (which implements lasso regression), but I can’t make the ROC charts from this. library(glmnet) glm_net <- cv.glmnet(dev_x_matrix,dev_y_vector,family="binomial",type.measure="class") phat <- predict(glm_net,newx=val_x_matrix,s="lambda.min") That gets me a vector with what looks like a log of the fitted values. I was trying to generate some ROC charts after this but it did not work. I think it is because of the nature of the x and y objects which

R: glmnet: forcing the coefficient to a certain sign

大城市里の小女人 提交于 2020-01-03 16:58:08
问题 I have a very large matrix, so I am using glmnet for a regression. I have a condition that names with p must have a positive coefficient and names with n a negative coefficient. How can I force this condition in glmnet? Below is a small example as an illustration: library(glmnet) y <- cumsum(sample(c(-1, 1),100, TRUE)) p1 <- cumsum(sample(c(-1, 1),100, TRUE)) p2 <- cumsum(sample(c(-1, 1),100, TRUE)) p3 <- cumsum(sample(c(-1, 1),100, TRUE)) n1 <- cumsum(sample(c(-1, 1),100, TRUE)) n2 <- cumsum

Running glmnet package in R, getting error “missing value where TRUE/FALSE needed”, maybe due to missing values?

∥☆過路亽.° 提交于 2020-01-02 08:11:23
问题 I am trying to use glmnet from the glmnet package to run a LASSO regression. I am using the following command: library(glmnet) glmnet(a,b,family="binomial",alpha=1) And am getting the error: > Error in if (!all(o)) { : missing value where TRUE/FALSE needed a is a matrix, with numerical values. b is a vector with a factor as values. However, b has some missing values. I am suspecting this might be what is causing the error. However, I don't see an option to exclude NA s in the glmnet

Running glmnet package in R, getting error “missing value where TRUE/FALSE needed”, maybe due to missing values?

ε祈祈猫儿з 提交于 2020-01-02 08:11:12
问题 I am trying to use glmnet from the glmnet package to run a LASSO regression. I am using the following command: library(glmnet) glmnet(a,b,family="binomial",alpha=1) And am getting the error: > Error in if (!all(o)) { : missing value where TRUE/FALSE needed a is a matrix, with numerical values. b is a vector with a factor as values. However, b has some missing values. I am suspecting this might be what is causing the error. However, I don't see an option to exclude NA s in the glmnet

Extract the coefficients for the best tuning parameters of a glmnet model in caret

时光总嘲笑我的痴心妄想 提交于 2019-12-30 06:51:21
问题 I am running elastic net regularization in caret using glmnet . I pass sequence of values to trainControl for alpha and lambda, then I perform repeatedcv to get the optimal tunings of alpha and lambda. Here is an example where the optimal tunings for alpha and lambda are 0.7 and 0.5 respectively: age <- c(4, 8, 7, 12, 6, 9, 10, 14, 7, 6, 8, 11, 11, 6, 2, 10, 14, 7, 12, 6, 9, 10, 14, 7) gender <- make.names(as.factor(c(1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1)))

Python glmnet “No module named _glmnet”

穿精又带淫゛_ 提交于 2019-12-24 05:03:40
问题 UPDATE Getting close. Now I'm running f2py on the .pyf file that should generate the _glmnet module. I build the package python-glmnet packet with the following command. python setup.py config_fc --fcompiler=gnu95 --f77flags='-fdefault-real-8' --f90flags='-fdefault-real-8' build But when I import the module I get this error: File "/Users/rose/221/tagger/tagger/glmnet/glmnet.py", line 2, in import _glmnet ImportError: No module named _glmnet How can I import that module? The glmnet directory