Two weight vectors fit a training set equally well: wA=(3,0) and wB=(1.5,1.5). Ridge adds the penalty λ∑jwj2 and lasso adds λ∑j∣wj∣, with λ=0.1. Compute both penalties for each vector. Which vector does each method prefer?

Supervised learning, Regularisation
Level L2 Elementary. Length Short. Nature Th+Mat Both.

What's being asked

Whether you can compute the L2 and L1 penalties of a weight vector and see how they treat "spread out" and "concentrated" weights differently.

Key idea

Ridge penalises the squared size of each weight, so one large weight costs much more than two half-size weights. Lasso penalises the absolute size, which is the same for both choices here. With equal fit, the method with the lower penalty wins.

Steps

  1. Ridge penalty of wA: ∑wj2=32+02=9, so the penalty is 0.1×9=0.9.
  2. Ridge penalty of wB: 1.52+1.52=2.25+2.25=4.5, so the penalty is 0.1×4.5=0.45.
  3. Lasso penalty of wA: ∣3∣+∣0∣=3, so 0.1×3=0.3. Of wB: 1.5+1.5=3, so 0.1×3=0.3.
  4. Conclude. Ridge prefers wB (0.45 against 0.9): it likes to share weight across features. Lasso sees a tie (0.3 each): it does not mind concentrating weight on one feature, which is the first hint of why lasso can set weights to exactly zero.

Common mistakes

How long your answer should be

About 2 minutes: four small sums and one sentence of interpretation.

Read this

Previous in Supervised learning: A linear regression model predicts monthly rent, in thousands of rupees, as y^=5+0.02 a+3 r, where a is the flat's area in square feet and r is the number of bedrooms. (a) What rent does it predict for a 600 sq ft flat with 2 bedrooms? (b) What does the number 3 mean? (c) Two flats both have 2 bedrooms but one is 100 sq ft larger. How much more rent does the model predict for it?
Next in Supervised learning: How do you derive the hard-margin SVM objective, and why is the margin 2∥w∥, where w is the weight vector?