What is the difference between L1 and L2 regularization in Machine Learning models?
I am training a high-dimensional dataset and my model is overfitting. I’m confused between using Lasso (L1) and Ridge (L2) regression. Which one should I use if I suspect that only a few of my features are actually important, and how do they physically change the cost function?
2025-01-12 in Machine Learning by Michael Scott
| 15948 Views
All answers to this question.
The primary difference lies in how they penalize large weights. L2 (Ridge) adds a penalty equal to the square of the magnitude of coefficients, which tends to shrink all coefficients evenly but never sets them to zero. L1 (Lasso) adds a penalty equal to the absolute value of the magnitude, which has a unique property: it can force some coefficients to exactly zero. If you have many features but suspect only a few are relevant, Lasso is your best friend because it performs automatic feature selection. In a 2024 pricing model I built, L1 allowed me to reduce 150 potential variables down to the 12 most impactful ones, making the final model much more interpretable and faster to run in production.
Answered 2025-02-14 by Susan Thompson
Can you combine both if you have a mix of highly correlated features and also want some feature selection to occur simultaneously?
Answered 2025-03-01 by David Martinez
-
David, that is exactly what "Elastic Net" regression is for! It combines the penalties of both L1 and L2. It’s particularly useful when you have groups of correlated variables; Lasso might just pick one at random from the group, while Elastic Net will include the whole group but keep the overall model sparse. It’s a very powerful compromise for complex datasets.
Commented 2025-03-10 by James Lee
I usually start with Ridge (L2) to see the baseline performance and then move to Lasso (L1) if I need to simplify the model for the engineering team.
Answered 2025-03-15 by Linda Robinson
-
That’s a smart iterative approach, Linda. Ridge is generally more stable when features are correlated, so it’s a great starting point before you get aggressive with feature elimination.
Commented 2025-03-20 by Michael Scott
Write a Comment
Your email address will not be published. Required fields are marked (*)

