L1 or L2 regularization for feature selection?
Which Regularization Actually Helps You Choose the Right Features?
When it comes to feature selection, L1 and L2 regularization play distinct roles:
🔹 L1 Regularization (Lasso):
L1 Regularization adds a penalty equal to the absolute value of the magnitude of coefficients.
L1 regularization encourages sparsity in the model. It can shrink some coefficients exactly to zero, effectively performing feature selection by excluding these features from the model.
By setting some coefficients to zero, L1 regularization helps in identifying which features are most important, making the model more interpretable.
🔹 L2 Regularization (Ridge):
L2 Regularization adds a penalty equal to the square of the magnitude of coefficients.
L2 regularization penalizes large coefficients but does not set them exactly to zero. It shrinks the coefficients towards zero, leading to a more stable model but does not inherently perform feature selection.
Having said this, we could still select the features with the largest coefficients as those would be driving the output of the prediction.
To learn more about feature selection, check out
📜 Our article: Feature selection with Lasso in Python
🎓 Our course: Feature Selection for Machine Learning
📘 Our book: Feature Selection in Machine Learning
And that’s not all—great news! ELI5 now supports scikit-learn 1.6.0!
Great news: ELI5 now works with scikit-learn 1.6.0!
Some of you noticed that ELI5 wasn't working with the latest version of scikit-learn.
You probably even modified the code locally to make it work (if you are taking my course or checking ELI5's issues you probably did).
Well, that's a thing of the past!
Last week, ELI5 released a new version that now fully supports the latest version of scikit-learn AND python 3.10 and above!
That's great news, because it means that ELI5 is here to stay and we can continue analyzing our models locally with it.
Thanks to Konstantin Lopukhin for the update and release!
Ready to enhance your skills?
Our specializations, courses and books are here to assist you:
Advanced Machine Learning (specialization)
Forecasting with Machine Learning (course)



