Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is LASSO regression implemented in Statsmodels?

I would love to use a linear LASSO regression within statsmodels, so to be able to use the 'formula' notation for writing the model, that would save me quite some coding time when working with many categorical variables, and their interactions. However, it seems like it is not implemented yet in stats models?

like image 251
famargar Avatar asked Apr 17 '17 07:04

famargar


1 Answers

Lasso is indeed implemented in statsmodels. The documentation is given in the url below:

http://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.OLS.fit_regularized.html

To be precise, the implementation in statsmodel has both L1 and L2 regularization, with their relative weight indicated by L1_wt parameter. You should look at the formula at the bottom to make sure you are doing exactly what you want to do.

Besides the elastic net implementation, there is also a square root Lasso method implemented in statsmodels.

like image 185
DiveIntoML Avatar answered Oct 25 '22 14:10

DiveIntoML