DS701 Session 14 — Wed Oct 21, 2026
When two columns of the design matrix are nearly linearly dependent (multicollinearity), the least-squares coefficients tend to become very large in magnitude. Explain in a sentence or two why that happens, how ridge regression’s penalty \(c\Vert\boldsymbol{\beta}\Vert_2^2\) addresses it, and what LASSO’s \(c\Vert\boldsymbol{\beta}\Vert_1\) penalty does that ridge cannot.
Fitting the Longley data, statsmodels warned that the condition number is about \(10^8\). Define \(\kappa(X)\) in terms of singular values. What does a huge value mean for the fitted coefficients \(\hat{\boldsymbol{\beta}}\), and what does it not mean for the fitted values? Why should you not compute \(\hat{\boldsymbol{\beta}}\) by forming and inverting \(X^\top X\)?
Before running ridge or LASSO the lecture standardized every column of \(X\). Plain least squares never needed that. Explain why a penalized fit does, and what LASSO is likely to do to a genuinely useful feature stored in units that make its numbers very small (say, income in millions of dollars) if you skip the step.
Lecture 07: flexible fits chase noise → high variance. Regularization is the knob:
\[ \min_{\boldsymbol{\beta}} \Vert X\boldsymbol{\beta} - \mathbf{y}\Vert_2^2 + c\,R(\boldsymbol{\beta}) \]

Ames housing, ridge (8 features with three collinear pairs, 100 random splits): held-out \(R^2\) rises with \(c\), then collapses — the sweet spot is found by cross-validation.

Same \(\mathbf{y}\); nearly parallel columns need \(\boldsymbol{\beta} = (5.60, -3.65)\) instead of \((1.60, -1.25)\).

The \(\ell_1\) diamond has corners on the axes; the contours usually hit a corner first, and a corner is an exact zero.
One standardized column, \(s = \mathbf{x}^\top\mathbf{x}\):
\[ \hat\beta_{\text{ridge}} = \frac{\hat\beta_{LS}}{1 + c/s} \]
\[ \hat\beta_{\text{lasso}} = \operatorname{sign}(\hat\beta_{LS})\max\!\big(|\hat\beta_{LS}| - \tfrac{c}{2s},\ 0\big) \]

TotRmsAbvGrd goes to zero first (its near-duplicate GrLivArea stays), then YearBuilt, GarageArea and 1stFlrSF — from each collinear pair, one column is dropped.Today’s activity, Part 2: coefficient paths for both penalties on data where you know which features matter, CV to pick \(\alpha\), and one fit where you “forget” to standardize and watch the lasso throw away a real feature.
\[ \min_{\boldsymbol{\beta}}\; -\ell(\boldsymbol{\beta}) + c\Vert\boldsymbol{\beta}\Vert_2^2 \qquad\text{or}\qquad -\ell(\boldsymbol{\beta}) + c\Vert\boldsymbol{\beta}\Vert_1 \]
sklearn’s LogisticRegression() does this by default: \(\ell_2\), C=1.0, and \(C = 1/c\) — smaller C = more penalty.C=np.inf (older versions: penalty=None) gives back the plain MLE fit of 11A.C by CV.Admissions, standardized features:
| no penalty | C=1 |
C=0.01 |
|
|---|---|---|---|
gre |
0.265 | 0.263 | 0.148 |
gpa |
0.295 | 0.292 | 0.148 |
rank |
−0.528 | −0.521 | −0.233 |
\(n = 400\): the default barely moves anything; \(c = 100\) roughly halves every coefficient.
The client: the same credit union’s small-business lending desk.
The data: a simulator of the desk’s applicants, whose true answer you know
Report out: a memo to the desk — which attributes to check, and the one caveat they must hear.
numpy, pandas, matplotlib, scikit-learn.The activity notebook goes live on the day of the lecture. Colab is optional — you can also open it on GitHub and run it locally.
Full lecture notes: Regularization
sklearn’s C = 1/c