All problems
LASSO Coordinate Step
Problem
Compute one coordinate-descent update for LASSO.
Given the partial residual inner product rho_j and z_j = ||X_j|| ** 2, return soft_threshold(rho_j, lam) / z_j: (rho_j - lam) / z_j when rho_j > lam, (rho_j + lam) / z_j when rho_j < -lam, and 0.0 in between. If z_j is not positive, return 0.0.
Hint
Soft threshold the inner product, then divide by the feature norm squared.
Test cases
case 1
in: [0.5,1,2,0.25]
expected: 0.375
case 2
in: [0.5,0.1,2,0.25]
expected: 0
case 3
in: [0.5,-1,4,0.5]
expected: -0.125
case 4
in: [0.5,0.3,0,0.1]
expected: 0
Starter codePython
def lasso_coordinate_step(x_j, rho_j, z_j, lam):
# Your code here
pass4 test cases · run your code against them in the editor