Contents
07A Bayesian view: penalties are priors
7.1From prior to penalty
A third way to understand the two penalties is through probability. Assume the targets are the linear model plus Gaussian noise, y_i=x_i^\top w+\varepsilon_i with \varepsilon_i\sim\mathcal N(0,\sigma^2) independent, and put a prior distribution p(w) on the weights that expresses what we believe before seeing data. Bayes’ rule gives the posterior p(w\mid y)\propto p(y\mid w)\,p(w), and the most probable weights, the maximum a posteriori (MAP) estimate, maximize it. Taking -\log turns the product into a sum:
Gaussian prior. If the weights are independent \mathcal N(0,\tau^2), then -\log p(w)=\|w\|_2^2/(2\tau^2)+\text{const}. Multiplying the objective by 2\sigma^2 gives ridge regression,
Laplace prior. If the weights are independent with the Laplace (double-exponential) density p(w_j)=\frac{1}{2b}e^{-|w_j|/b}, then -\log p(w)=\|w\|_1/b+\text{const} and the same steps give the lasso,
Tibshirani (1996) already noted that the lasso estimate is the posterior mode under independent Laplace priors.
7.2What the priors say
The formulas match intuition. \lambda=\sigma^2/\tau^2 is large when the noise \sigma^2 is large (do not trust the data) or the prior spread \tau^2 is small (believe the weights are small): more regularization. The Gaussian prior is smooth and flat at zero; it says “weights are probably small” but gives zero no special status, so its mode is never exactly zero. The Laplace prior has a sharp peak at zero and heavier tails; it says “most weights are probably exactly negligible, and a few may be large”, which is the sparse belief, and the peak is the same corner as in Figure 2(a). One caution: only the posterior mode of the Laplace model is sparse. Its posterior mean, which a fully Bayesian analysis would report, is not (Hastie et al., 2015). MAP estimation versus maximum likelihood is the topic of the next episode, Episode 5.
Worked example 7. In Figure 1 the noise standard deviation is \sigma=0.3 and cross-validation chose \lambda=0.0157. By (14) this is the MAP estimate under a Gaussian prior with standard deviation \tau=\sigma/\sqrt\lambda=0.3/\sqrt{0.0157}=2.40 on each standardized coefficient. The data chose a prior that allows coefficients of a few units, ruling out the values above 1{,}000 that least squares produced.
Pause and think. Which prior would produce the elastic net (13) as its MAP estimate?
Show the answer
A prior with density proportional to \exp\!\big(-c_1\|w\|_1-c_2\|w\|_2^2\big), a compromise between Laplace and Gaussian: it has the Laplace corner at zero and Gaussian, lighter tails far from zero. Matching the terms gives \lambda_1=2\sigma^2c_1 and \lambda_2=2\sigma^2c_2.