4.4 Practical Considerations

DATA 442/642 · Week 4 · PDF · Slides

Tuning, scaling, and what to watch for in sparse models.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

The figures follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning, and Theodoridis, Machine Learning: A Bayesian and Optimization Perspective.

1. Paths under ℓ1 and ℓ2

Gradient paths with <math xmlns=ℓ1 and ℓ2 penalties" src="files/graphics/4.4-sparsity-practical/Optimization.png" />

Left. Contours of unregularized MSE plus an ℓ1 penalty with λ=0.5. The global min sits on the θ2=0 axis. Gradient descent hits θ2=0 first, then walks along the axis to the min.

Right. The same MSE plus an ℓ2 penalty.

On the LASSO cost the path bounces around the min after it reaches an axis. Shrink the learning rate during training so the steps get smaller and the walk can converge.


2. Elastic Net

Elastic Net puts both penalties on a linear model: ℓ1 (LASSO) and ℓ2 (ridge).

  • LASSO: sparsity and feature selection.
  • Ridge: multicollinearity and more stable coefficients.
J(θ)=12N‖𝐲−𝐗θ‖22+λ1‖θ‖1+λ2‖θ‖22.

3. Advantages and disadvantages

Advantages Disadvantages
High-dimensional data with multicollinearity Two penalty weights to tune
Feature selection with correlated predictors Less intuitive than LASSO or ridge alone
A compromise between LASSO and ridge Higher computational cost; less sparse than LASSO; sensitive to feature correlations

4. Practice

  1. Why does gradient descent on the LASSO cost bounce near an axis, and what do you change so it can settle?

  2. What two penalties does Elastic Net mix, and what does each one contribute?

  3. Name one advantage and one disadvantage of Elastic Net relative to LASSO.