Lasso regression is a form of regression analysis used for variable selection and regularization. Use this tag for programming questions related to Lasso regression only. You can ask statistical questions on Cross Validated instead
Questions tagged [lasso-regression]
457 questions
1
vote
1 answer
Inconsistent results trying to reproduce the variables selected by LASSO ran using enet(lambda = 0) with lars(type = "lasso")
The scripts which are referenced and from which the lines of code included came from can all be found at my GitHub Repository for this project, along with mini practice datasets (called ten, top 50, and last 50) so that you can replicate my…

Marlen
- 171
- 11
1
vote
1 answer
Can glmmLasso be used with the Tweedie distribution?
I have a linear mixed effects model and I am trying to do variable selection. The model is testing the level of forest degradation in 1000 sampled points. Most points have no degradation, and so the dependent variable is highly skewed with many…

Matt Marcus
- 13
- 3
1
vote
1 answer
Validation but not cross validation in Python sklearn Lasso
I need to train a LASSO model using sklearn. I am given a pair of specifically designed training and validation datasets.
The goal is to let the algorithm autogenerate a sequence of alphas (the L1 penalty strength), and for each alpha, fit a model…

user2961927
- 1,290
- 1
- 14
- 22
1
vote
1 answer
How to replicate my results from running n LASSOs iteratively using elastic net but now with glmnet
I have successfully run LASSO Regressions on each of n data sets within the 'datasets' list in my R Environment/Workspace using the enet function from the elastic net library in R, but just to ensure there is nothing arbitrary about my results based…

Marlen
- 171
- 11
1
vote
0 answers
Implementing regularization Pytorch vs Keras
Do you know what would be the analog of doing something like this in Keras?
alpha = 5
pearson_corr = correlation.calculate_correlation(train)
pearson_index = [x for x in range(len(pearson_corr)) if abs(pearson_corr[x])<0.3]
self.corr_l1_penalty =…

Caterina
- 775
- 9
- 26
1
vote
0 answers
cv.glmnet crashing in R studio, when trying to run a multinomial regression with LASSO penalty
I am trying to run cv.glmnet with family="multinomial".
However whenever I run it, RStudio crashes. I have also tried just running it from the command line, but this then just quits R.
My response classes are given in matrix from and I have a…

Dylan Dijk
- 277
- 1
- 6
1
vote
0 answers
SKlean's LassoCV with regularization parameter per target
For linear regressions, alphas (regularization parameters) are usually obtained via cross-validation.
My goal is to perform regression for each target dimension. So that the alpha is defined for each target dim. Assuming that my input data size is…

Minkyu Choi
- 389
- 5
- 13
1
vote
1 answer
How could one use either an lapply or a For Loop combined with an IF in R to return just the names of LASSO IVs with coefficients > 0?
I have via lots of legwork and previous helpful answers to previous Stackoverflow questions successfully ran a uniquely fit LASSO Regression to each of my 47,000 individual 500 row by 31 columns (30 IVs & 1 DV columns) datasets for a research…

Marlen
- 171
- 11
1
vote
1 answer
lasso regression in scikit-learn does not have option to be run in muti-threading
I have a huge dataset as input for a multiple lasso fit. The predictor values have size of 1250 by 1milion and the target value is 1250 by 1250
If I fit a normal regression by sklearn there there is an option to use multiple threads which in this…

mjoudy
- 149
- 1
- 1
- 10
1
vote
1 answer
Is there a simple way to generalize code which successfully fits a LASSO Regression to a single csv to n csvs in a file folder?
My goal/task is to fit a LASSO Regression function using the enet() function from the elastic net package in R to each of the 47,000 individual csv file formatted datasets which are all located in the same large file folder called "sample_obs". Each…

Marlen
- 171
- 11
1
vote
1 answer
Adjust threshold in cros_val_score sklearn for Lasso
I saw this post that trained a LGBM model but i would like to know how to adapt it for Lasso. I know the prediction may not necessarily be between 0 and 1, but I would like to try this model. I have tried this but it doesnt work:
import numpy as np…

Stephy Riega
- 11
- 1
1
vote
0 answers
cross_val_score and LassoCV.score() produce different r2 scores
I thought those two methods should produce similar scores but then I got different scores. Here are my codes:
#prepare the data and model
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,train_size = 0.7,test_size = 0.3,random_state = 10)
kf =…

juneliu
- 11
- 2
1
vote
0 answers
LASSO is slow to run?
I have a large dataset that I've been trying to run a lasso regression on. Categorical variables are re-coded to dummies. After receiving several messages regarding limited memory, I converted my data into a sparse matrix using Matrix.
The issue is…

thou
- 35
- 4
1
vote
1 answer
How to capture the most important variables in Bootstrapped models in R?
I have several models that I would like to compare their choices of important predictors over the same data set, Lasso being one of them. The data set I am using consists of census data with around a thousand variables that have been renamed to…

jad
- 11
- 2
1
vote
1 answer
if (any(const_vars)) missing value where TRUE/FALSE needed error while running Lasso in R
When I tried to run a Lasso Regression on my 51th response variable with the other 50 variables, I got the following error message:
lasso_now=cv.glmnet(x=as.matrix(scaledData[,-51]),y=as.matrix(scaledData[,51]),alpha=1,nfolds =…

Edison Lin
- 25
- 5