Explain the difference between L1 and L2 regularization.

Explain the difference between L1 and L2 regularization.

Approach: Compare the penalty terms and their effect on coefficients.

L1 (Lasso) adds a penalty equal to the absolute value of the magnitude of coefficients, which can force some coefficients to zero (feature selection). L2 (Ridge) adds a penalty equal to the square of the magnitude, shrinking coefficients toward zero but rarely making them exactly zero.

Follow-up: When would you choose L1 over L2?

Key concepts: sparsity, weight decay, norm.