Lasso case

For Lasso we need now, keeping a constraint on \( \vert\theta_0\vert+\vert\theta_1\vert=1 \), to take the derivative of the absolute values of \( \theta_0 \) and \( \theta_1 \). This gives us the following derivatives of the cost function

$$ C(\boldsymbol{\theta})=(4-2\theta_0)^2+(2-\theta_1)^2+\lambda(\vert\theta_0\vert+\vert\theta_1\vert), $$ $$ \frac{\partial C(\boldsymbol{\theta})}{\partial \theta_0}=-4(4-2\theta_0)+\lambda\mathrm{sgn}(\theta_0)=0, $$

and

$$ \frac{\partial C(\boldsymbol{\theta})}{\partial \theta_1}=-2(2-\theta_1)+\lambda\mathrm{sgn}(\theta_1)=0. $$

We have now four cases to solve besides the trivial cases \( \theta_0 \) and/or \( \theta_1 \) are zero, namely

  1. \( \theta_0 > 0 \) and \( \theta_1 > 0 \),
  2. \( \theta_0 > 0 \) and \( \theta_1 < 0 \),
  3. \( \theta_0 < 0 \) and \( \theta_1 > 0 \),
  4. \( \theta_0 < 0 \) and \( \theta_1 < 0 \).