ValueError: Solver lbfgs supports only 'l2' or 'none' penalties, got l1 penalty

As l1 is supported by solver 'liblinear'. Always specify solver='liblinear' with penalty= 'l1'

selection = SelectFromModel(LogisticRegression(C=1, penalty='l1', solver='liblinear'))


This is cleared up in the documentation.

solver : {‘newton-cg’, ‘lbfgs’, ‘liblinear’, ‘sag’, ‘saga’}, default=’lbfgs’

...

  • ‘newton-cg’, ‘lbfgs’, ‘sag’ and ‘saga’ handle L2 or no penalty

  • ‘liblinear’ and ‘saga’ also handle L1 penalty

Call it like this:

LogisticRegression(C=1, penalty='l1', solver='liblinear')

Just try to specify the solver that you want to use and then the error will be gone. l1 support 'liblinear' and 'saga' L2 handle newton-cg’, ‘lbfgs’, ‘sag’ and ‘saga’

clf = LogisticRegression(C=0.01, penalty='l1',solver='liblinear');