What is the difference between L1 and L2 regularization in logistic regression?

Quick Overview

Asks how L1 and L2 regularization differ in logistic regression: the penalty each adds to the log-loss, what each does to the coefficients, and when to prefer one or Elastic Net. It tests your grasp of sparsity, shrinkage, correlated features and tuning the penalty strength.

What is the difference between L1 and L2 regularization in logistic regression?

Role: Data Scientist

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What is the difference between L1 and L2 regularization in logistic regression? Both add a penalty on the coefficients to the log-loss. Explain how the two penalties differ and what each one does to the fitted model. ```hint Look near zero Compare how the slope of each penalty behaves as a coefficient gets close to 0. ``` ### What a Strong Answer Covers - The penalty term each method adds to the log-loss and how its strength is set. - Why one penalty produces coefficients that are exactly zero and the other does not, with a geometric or gradient argument. - How each penalty behaves when predictors are strongly correlated. - When to pick L1, L2, or a mix of the two. - Practical details: feature scaling, the intercept, and how the strength is tuned. ### Follow-up Questions - With two perfectly correlated features, what does each penalty do to their two coefficients? - How would you choose the regularization strength, and how does scikit-learn's `C` relate to $\lambda$? - Why do L1-regularized fits need solvers such as coordinate descent or proximal methods? - How does stronger regularization change the predicted probabilities?

Overview: Asks how L1 and L2 regularization differ in logistic regression: the penalty each adds to the log-loss, what each does to the coefficients, and when to prefer one or Elastic Net. It tests your grasp of sparsity, shrinkage, correlated features and tuning the penalty strength.

Nov 25, 2026
easyData ScientistOtherMachine Learning
0
0

What is the difference between L1 and L2 regularization in logistic regression?

Both add a penalty on the coefficients to the log-loss. Explain how the two penalties differ and what each one does to the fitted model.

What a Strong Answer Covers Guidance

  • The penalty term each method adds to the log-loss and how its strength is set.
  • Why one penalty produces coefficients that are exactly zero and the other does not, with a geometric or gradient argument.
  • How each penalty behaves when predictors are strongly correlated.
  • When to pick L1, L2, or a mix of the two.
  • Practical details: feature scaling, the intercept, and how the strength is tuned.

Follow-up Questions Guidance

  • With two perfectly correlated features, what does each penalty do to their two coefficients?
  • How would you choose the regularization strength, and how does scikit-learn's C relate to λ\lambda ?
  • Why do L1-regularized fits need solvers such as coordinate descent or proximal methods?
  • How does stronger regularization change the predicted probabilities?