What is the difference between L1 and L2 regularization?

Quick Overview

Asks how L1 and L2 regularization differ in their penalty, their effect on model weights, and when to use each. Tests whether you can explain which penalty yields sparse models and why, how each handles correlated features, and how each is optimized.

What is the difference between L1 and L2 regularization?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

Both L1 and L2 regularization add a penalty on the model's weights to the training loss. What is the difference between them? ```hint Compare the gradients Write each penalty and its gradient, then ask what each gradient does to a weight that is already close to zero. ``` ### What a Strong Answer Covers - The form of each penalty - Why one penalty produces weights that are exactly zero and the other does not, from the gradient or the geometry - How each behaves when features are correlated - How each is optimized, and when to choose L1, L2 or a mix of the two ### Follow-up Questions - Why should features be standardized before applying either penalty? - What prior does each penalty correspond to in a Bayesian view? - How does Elastic Net change L1's behavior on a group of correlated features? - With the Adam optimizer, is adding an L2 term to the loss the same as weight decay?

Overview: Asks how L1 and L2 regularization differ in their penalty, their effect on model weights, and when to use each. Tests whether you can explain which penalty yields sparse models and why, how each handles correlated features, and how each is optimized.

PracHub logo
General
Nov 24, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

Both L1 and L2 regularization add a penalty on the model's weights to the training loss. What is the difference between them?

What a Strong Answer Covers Guidance

  • The form of each penalty
  • Why one penalty produces weights that are exactly zero and the other does not, from the gradient or the geometry
  • How each behaves when features are correlated
  • How each is optimized, and when to choose L1, L2 or a mix of the two

Follow-up Questions Guidance

  • Why should features be standardized before applying either penalty?
  • What prior does each penalty correspond to in a Bayesian view?
  • How does Elastic Net change L1's behavior on a group of correlated features?
  • With the Adam optimizer, is adding an L2 term to the loss the same as weight decay?