← Microsoft Interview Insights
I knew the basics, L1 pushes weights to zero so you get sparsity, L2 penalizes large weights but keeps them small rather than zeroing them out.
Start by defining L1 and L2 regularization mathematically, then contrast their effects on model weights and sparsity. Explain when to use each, highlighting practical implications like feature selection and overfitting prevention, and mention computational considerations.
Pro tip: Emphasize that L1 is preferred for sparse solutions and feature selection, while L2 is better for preventing overfitting when all features are relevant; also note that Elastic Net combines both, showing depth.
State that L1 adds the sum of absolute weights to the loss, while L2 adds the sum of squared weights. Mention the regularization parameter lambda.
Describe how L1 encourages sparsity by driving some weights to exactly zero, while L2 shrinks weights towards zero but rarely to exactly zero.
L1 is useful for feature selection and interpretable models; L2 is useful when all features contribute and you want to avoid overfitting without eliminating features.
L1 is non-differentiable at zero, requiring techniques like subgradient or coordinate descent; L2 is differentiable and has closed-form solutions in linear regression.
Conclude that choice depends on problem: L1 for sparsity, L2 for smoothness, and Elastic Net for combining both.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.