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

| improve this answer | |
  • $\begingroup$ Thanks. So the magic attribute is coef_, called on the LogisticRegression object after fitting, eg. alg.coef_. $\endgroup$ – Atte Juvonen Sep 24 '16 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.