L1 (lasso) adds the sum of absolute coefficients to the loss and drives some coefficients exactly to zero, so it performs feature selection. L2 (ridge) adds the sum of squared coefficients, shrinking everything toward zero without eliminating anything, which handles correlated predictors more gracefully. Pick L1 when you want a sparse, explainable model; pick L2 when predictors are correlated and you want stability.
Why interviewers ask this
Anyone can recite lasso versus ridge. The interviewer wants the geometric or practical reason L1 produces exact zeros, and they want to hear that you scale features first, because both penalties are meaningless on unscaled data. Mentioning elastic net as a pragmatic default and describing how you choose the penalty strength through cross validation separates a practitioner from someone repeating a textbook line.
How to structure your answer
- State the penalty term for each in plain language.
- Explain why L1 hits exact zeros and L2 does not.
- Mention that features must be scaled before either penalty means anything.
- Say how you choose the strength, and name elastic net as a middle ground.
Example answer
L2 squares the coefficients and shrinks them all smoothly toward zero. L1 uses absolute values, and because that penalty has a corner at zero, the optimum often lands exactly on zero, which is why lasso doubles as feature selection. The practical rule I use is about correlation. If I have a block of highly correlated predictors, lasso picks one almost arbitrarily and zeros the rest, which looks tidy but is unstable: refit on a bootstrap sample and it picks a different one. Ridge keeps them all and splits the weight, which is usually more honest. If a stakeholder needs a short list of drivers, I take the lasso and accept the instability, but I say out loud that the survivors are representatives of a correlated group, not the only things that matter. In practice I usually reach for elastic net so I get some sparsity without the arbitrary picking, and I tune the strength by cross validation. And I always standardize first, because otherwise the penalty just punishes whichever feature happens to be measured in small units.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- Why does the L1 penalty produce exact zeros geometrically?
- What happens to ridge coefficients as the penalty goes to infinity?
- How would you tune the penalty strength when you also have class imbalance?
Related data scientist questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions