← Microsoft Interview Insights

Microsoft·Machine Learning Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Microsoft ML engineer interview, got asked a pretty standard regularization question. Nothing too wild but it's the kind of thing that trips you up if you haven't thought about it carefully in a while.

Questions Asked (1)

Q1

What are the differences between L1 and L2 regularization?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

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.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Define L1 and L2

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.

2. Explain effect on weights

Describe how L1 encourages sparsity by driving some weights to exactly zero, while L2 shrinks weights towards zero but rarely to exactly zero.

3. Discuss use cases

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.

4. Mention computational aspects

L1 is non-differentiable at zero, requiring techniques like subgradient or coordinate descent; L2 is differentiable and has closed-form solutions in linear regression.

5. Summarize with trade-offs

Conclude that choice depends on problem: L1 for sparsity, L2 for smoothness, and Elastic Net for combining both.

Key Points to Mention

  • Mathematical formulas: L1 = λ * sum(|w_i|), L2 = λ * sum(w_i^2)
  • Sparsity: L1 yields sparse models, L2 does not
  • Feature selection: L1 can automatically select features, L2 cannot
  • Overfitting prevention: both reduce overfitting, but L2 is often more stable
  • Computational: L2 has closed-form solutions, L1 does not
  • Elastic Net: combines L1 and L2 to get benefits of both

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.