2.2.14 · D5Linear & Logistic Regression

Question bank — L2 (Ridge) regularization

1,543 words7 min readBack to topic

The three figures below make the geometry concrete — refer back to them as the questions mention constraints, the U-curve, and SVD shrinkage.

Figure — L2 (Ridge) regularization
Figure — L2 (Ridge) regularization
Figure — L2 (Ridge) regularization

True or false — justify

Ridge always produces a lower training error than OLS.
False. Ordinary Least Squares minimizes training error alone, so nothing can beat it on training data; adding the fee can only raise training error. Ridge wins on test error.
As every weight goes to exactly zero including the intercept.
False (mostly). The penalized weights shrink toward , but the intercept is not penalized, so predictions collapse to the mean of , not to .
At Ridge and OLS give the identical solution.
True — the penalty term vanishes, so becomes the pure OLS cost and , provided is invertible.
Ridge can be used even when the number of features exceeds the number of examples .
True. OLS fails because is singular, but with is strictly positive definite and thus invertible — Ridge cures the ill-posed case.
Increasing always improves test error.
False. Test error typically dips then rises (the U-shape in the middle figure): too little overfits, too much underfits. There is a sweet spot found by Cross-Validation.
The Ridge penalty makes the cost function convex.
True (and it was already convex). OLS cost is convex; adding (a convex bowl) keeps it convex and makes it strictly convex, so the minimum is unique.
Ridge performs feature selection.
False. L2 shrinks weights smoothly but almost never sets one exactly to ; that is the job of L1 (Lasso) regularization, whose diamond-shaped constraint has corners on the axes (left figure).
Standardizing features before Ridge changes which model you get.
True. Because penalizes every weight equally, unequal feature scales make the penalty unfair; standardization (Feature Scaling / Standardization) is what makes Ridge scale-invariant.
The SVD shrinkage factor can exceed 1.
False. Since and , the denominator is always the numerator, so the factor lies in for and equals only when — it only ever shrinks, never amplifies.

Spot the error

"Ridge sets useless features to zero, so I read off the zero weights to do feature selection."
The weights are small, not zero — the circular constraint has no corners touching the axes (left figure). Use L1 (Lasso) regularization or Elastic Net for genuine sparsity.
"I picked by choosing the value that gave the lowest training MSE."
Training MSE is monotonically increasing in , so it always votes . is a hyperparameter and must be tuned on held-out data via Cross-Validation.
"I penalized all weights including so the math is uniform."
The intercept sets the output baseline; shrinking it biases predictions toward for no reason. Exclude from the penalty (or center first).
" was singular so Ridge cannot be computed either."
Wrong direction — adding () is precisely what makes invertible. Singularity is what Ridge is built to fix.
"Two duplicate features got weights and under Ridge, that's how it handles correlation."
That giant-cancelling pattern is the OLS pathology. Ridge minimizes , so it prefers small equal weights (e.g. each) that sum to the same signal — cheaper norm.
"I fit Ridge on raw features (meters vs millimeters), the penalty handled it automatically."
A feature in millimeters carries a smaller weight, so its penalty contribution is tiny and unfair. Standardize first — the penalty does not fix scale mismatch by itself.
"I standardized all my data first, then split into train and test — clean pipeline."
That is data leakage: the scaler saw the test set's mean and variance, so information bled into training. Fit the scaler on the training fold only, then apply those same statistics to validation/test.

Why questions

Why "squared" weights instead of just requiring a good fit?
Correlated features let OLS pick huge opposite weights that cancel on training data but explode on new data; the fee makes such large-magnitude combinations expensive, forcing calmer weights.
Why does Ridge trust high-singular-value directions and distrust low ones?
The factor is when is large (well-measured, high-signal) and when is small (noisy, unstable) — so weak, noisy directions are shrunk away (right figure).
Why is a small increase in bias worth it?
Test error ; Ridge trades a tiny bias increase for a large variance drop, a net reduction — the core Bias-Variance Tradeoff.
Why is the constrained view () equivalent to the penalty view?
Every choice of in the penalty corresponds to some budget in "minimize the fit subject to ." Geometrically (left figure): the best point sits where the elliptical loss contours first touch the constraint ball — and at that touch point, the two forces (pull-toward-OLS vs push-toward-origin) balance, which is exactly the stationary condition the term encodes. A bigger pushes harder, shrinking the ball to a smaller .
Why is Ridge's constraint region a ball while Lasso's is a diamond?
is a sphere (smooth, no corners), so the tangency with the loss contours is generically off-axis → nonzero weights; L1's has corners on the axes → exact zeros (left figure contrasts both).
Why doesn't Ridge ever set a weight to exactly zero?
A smooth spherical constraint has no flat faces or corners resting on the coordinate axes, so the optimal tangency point almost never lands on an axis where a weight would be .

Edge cases

If a feature is pure noise (uncorrelated with ), what does Ridge do to its weight?
It shrinks the weight toward but leaves a small nonzero value; only L1 (Lasso) regularization can eliminate it entirely.
What is the Ridge solution when is exactly but is singular?
Undefined — the inverse does not exist. Any restores a unique solution; leaves us in the ill-posed OLS regime.
Two features are perfectly identical (correlation ). What does Ridge return?
It splits the required signal equally between them (smallest-norm split), since beats any lopsided combination giving the same fit — it never blows up as OLS can.
What happens to test error when features are already independent and well-scaled and you crank ?
Even here Ridge biases weights downward; if the data was not overfit, added mostly hurts by underfitting — regularization is not free when there was little variance to cut.
Does Ridge change the number of nonzero weights as grows?
No — the count stays at (all nonzero); only their magnitudes shrink. This is the sharpest behavioural contrast with Lasso, where the count drops.
For logistic classification, can this same L2 penalty be added?
Yes — Logistic Regression adds to its cross-entropy loss for the identical shrinkage effect, though there is no closed form (solved iteratively).
Recall Fastest self-check

Ridge shrinks (never zeros), needs standardized features (scaler fit on train only — no leakage), spares the intercept, tunes by cross-validation, and cures singular . Miss one and you've fallen into a trap above.