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.

Not startedJump to quiz

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 , .

ObjectiveABWinner
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

= #non-zeros; ; (intercept excluded).

Penalised objective by hand

1) Compute RSS (or ). 2) Compute the norm of the slopes. 3) Add λ × norm. Compare candidates on the same λ.

Regularised logistic

(ridge) or (LASSO).

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateFor , what are , and ?
Q2calculateA fit has RSS = 20 and ; take . What are the ridge, LASSO and L0 objectives?
Q3calculateA logistic fit has and ; . What is the LASSO-penalised objective?
Q4interpretFit A: RSS 10, . Fit B: RSS 13, . Under ridge with , which has the lower objective?
Q5calculateA fit has RSS = 12 and ; . What is the subset (L0) objective?