# Feature selection with L1 regularization on sklearn's LogisticRegression

I'm using sklearn's LogisticRegression with penaly=l1 (lasso regularization, as opposed to ridge regularization l2). Lasso is causing the optimization function to do implicit feature selection by setting some of the feature weights to zero (as opposed to ridge regularization, which will preserve all features with some non zero weight). Is it possible to extract this weight information (feature selection) from sklearn somehow?

Yes, as demonstrated in the documentation: http://scikit-learn.org/stable/auto_examples/linear_model/plot_logistic_path.html

Welcome to DataScience.SE

• Thanks. So the magic attribute is coef_, called on the LogisticRegression object after fitting, eg. alg.coef_. – Atte Juvonen Sep 24 '16 at 18:41