Connect L2 and L1 Penalties to Gaussian and Laplace Priors
Last updated: November 29, 2026
Quick Overview
Show that ridge and lasso regression are maximum a posteriori estimates under Gaussian and Laplace priors on the weights, and explain how the prior view helps you choose regularization strength for a Google Shopping price model.
0
0
0 solved
Show that ridge and lasso regression are maximum a posteriori estimates under Gaussian and Laplace priors on the weights, and explain how the prior view helps you choose regularization strength for a Google Shopping price model.
Data scientists at Google are expected to move between optimization and probabilistic views of a model. The interviewer checks the derivation and whether you can use the Bayesian lens to reason about how much to regularize and which weights to shrink.
What the Interviewer Expects
- Write the likelihood for linear regression with Gaussian noise
- Derive the MAP objective with a Gaussian prior, giving ridge with $\lambda = \sigma^2/\tau^2$
- Derive the Laplace prior case, giving lasso
- Interpret $\lambda$ as the ratio of noise variance to prior variance
- Mention that MAP is not the full posterior and that empirical Bayes or hierarchical priors can set $\lambda$
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- Why does the posterior mean under a Laplace prior not produce exact zeros while the MAP does?
- How would you use different priors for different feature groups?
- How does this view explain why more data needs less regularization?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Assume a linear model predicting log price from product features, with , and examples....
Approach
Write the posterior, take negative log, and match terms to the penalized objective....