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
2
votes
1 answer
Is there a parameter to set a penalty threshold in sklearn?
I am fitting an sklearn.linear_model.LogisticRegression model to my data with an L1 penalty as part of a feature selection process. It is my understanding that using penalty='l1' means that the optimization process will minimize a cost function…

Arturo Sbr
- 5,567
- 4
- 38
- 76
2
votes
0 answers
Run Lasso and Ridge logistic regression using statsmodels in Python
I want to run Lasso and Ridge logistic regression using statsmodel. I am getting the below error. Please suggest how to fetch fit.regularised for Ridge and Lasso regression.
P.S: I want to publish summary of the model result in the below format for…

Ussu
- 135
- 1
- 6
2
votes
1 answer
Sklearn.linear_model.Lasso returns coefficients that are both +0 and -0?
After training an ML model using https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html#sklearn.linear_model.Lasso, when I print out the coefficients, I can see that some of them give 0.00000000e+00 while others are…

programmer12
- 111
- 9
2
votes
1 answer
Shouldn't H2O standardize categorical predictors for regularized GLM models (lasso, ridge, elastic net)?
"The lasso method requires initial standardization of the regressors,
so that the penalization scheme is fair to all regressors. For
categorical regressors, one codes the regressor with dummy variables
and then standardizes the dummy variables" (p.…

Elliot
- 21
- 3
2
votes
0 answers
Interactively choose points with lasso in ggplotly?
I have a ggplot with points on it. I want to group these points into group based on their location, but I want to do it interactively with the "lasso" tool in plotly.
I can't figure out how to save the info from the group I've lassoed. I basically…

Jake L
- 987
- 9
- 21
2
votes
1 answer
How to find the fitted value in cv.glmnet or glmnet function in R?
Suppose I have generated the following data set and fitted the model using cv.glmnet function in R.
library(glmnet)
means <- c(-1, 1.3, 0.6, 2, 1.5, -0.7, 2.5)
size <- c(50, 50, 100, 200, 350, 50, 200)
t = list()
for (i in 1:length(means)) {
…

score324
- 687
- 10
- 18
2
votes
3 answers
Extracting non-zero coefficients in glmnet in R
I'm doing a lasso logistic regression. I've used cv.glmnet to get the non-zero coefficients. And it seems to work i.e. I do get some non-zero coefficients and the rest go to zero. However, when I use coef function to print all coefficients it gives…

Shafa Haider
- 413
- 2
- 5
- 13
2
votes
1 answer
Subset selection with LASSO involving categorical variables
I ran a LASSO algorithm on a dataset that has multiple categorical variables. When I used model.matrix() function on the independent variables, it automatically created dummy values for each factor level.
For example, I have a variable…

rookieg
- 81
- 1
- 5
2
votes
1 answer
Why is my Rcpp code is much slower than glmnet's?
I edited the lasso code from this site to use it for multiple lambda values.
I used lassoshooting package for one lambda value (this package works for one lambda value) and glmnet for multiple lambda values for comparison.
The coefficient…

mert
- 371
- 2
- 9
2
votes
1 answer
One-hot-encoded categorical variables in LASSO, how to compare variable importance?
I am working on a regression project in sklearn where I used LASSO regression on a variety of numeric and categorical variables. The categorical variables were transformed using the One-hot-encoder method.
Since the feature matrix was normalized in…

Xiaoyu Lu
- 3,280
- 1
- 22
- 34
2
votes
2 answers
Interpretation of Lasso regression results
I have a question related to a penalized regression model with Lasso and interpreting returning values. I have text content and want to find each the most predictive words for a class.
Code and Data
import numpy as np
import pandas as pd
import…

Christopher
- 2,120
- 7
- 31
- 58
2
votes
1 answer
Getting fixed effect estimates but not pvalues with glmmLasso
Hi I am trying perform a variable selection using the lasso approach, but my model includes a random effect.
I have run the model without the random effect using both the cv.glmnet and optL1 functions in glmnet and penalized (and got results);…

broch
- 97
- 6
2
votes
1 answer
Return x, y coordinates from Bokeh graph
I'm trying to adapt the answer from: Get selected data contained within box select tool in Bokeh
but get:
NameError: name 'inds' is not defined
after selecting the points.
Does anyone know whats going on?
Code I am using :
import pandas as…

user123328
- 63
- 1
- 10
2
votes
0 answers
Scikit-learn throwing warning for increased # of iterations for Lasso
I am trying to run Linear Regression with LASSO using Python's Scikit-learn package.
For Lasso, my configurations are as follows:
lasso_eps = 0.0001
lasso_alpha = 20
lasso_iter = 5000
And the code for the model is as follows:
lasso_cv =…

PankajK
- 187
- 3
- 14
2
votes
1 answer
R: how to add L1 norm line to plot from glmnet
I'm doing lasso regression, and I want to choose some beta coefficients that best explain my model by using Leave one out cross validation.
Here is my code:
library(glmnet)
set.seed(19875)
n=100
p=500
real_p=15
x=matrix(rnorm(n*p), nrow=n,…

Ville
- 547
- 1
- 3
- 21