Lesson 5.8 · 9 min read · about 50 min to master at a very slow pace
Mathematical Objectives and Worked Calculations
Norms, penalised objectives and how to compute ridge, LASSO and subset "errors" by hand, including choosing between two candidate fits, and penalised logistic regression.
Norms
For (the intercept is excluded):
is the "Manhattan distance" from zero; the squared Euclidean distance.
Example
: , , .
The three objectives
Computing the "errors" (objective values)
A fit has RSS and . Take .
- Ridge:
- LASSO:
- Subset: (three non-zero coefficients)
Choosing between two candidate fits
Fit A: RSS , . Fit B: RSS , .
| Objective | A | B | Winner |
|---|---|---|---|
| Ridge, | B | ||
| LASSO, | B | ||
| Ridge, | A |
With a small penalty the better-fitting model wins; with a big penalty the smaller-coefficient model wins.
Conventions differ
Some software divides RSS by (scikit-learn's Lasso) or uses RSS, which rescales what "λ" means. The story is identical (bigger penalty → smaller coefficients). If an exam question gives a formula, use that one.
Regularised logistic regression
The same idea applies to classification. Penalise the negative log-likelihood:
- Ridge-logistic: smooth shrinkage, stabilises optimisation.
- LASSO-logistic: sparsity; effective when or features are correlated.
- It fixes perfect separation: coefficients can no longer diverge.
- λ is chosen by CV, e.g. minimising log-loss or maximising AUC.
Penalised logistic objective by hand
, , . Ridge: . LASSO: .
Non-parametric models are regularised too: larger in K-NN, shallower trees, and in SVMs a smaller cost (6.7).
Cheatsheet
Norms
Penalised objective by hand
Regularised logistic
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.