Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-330

Lasso Coordinate Step Scalar

Problem

In coordinate descent for the Lasso, the scalar update is soft(b, lambda) / a where a is the squared column norm and b the partial correlation.

Given a > 0, b, and lambda, return the coordinate update.

Hint

Soft threshold the partial correlation, then divide by the column norm.

Test cases

case 1
in: [2,3,0.5]
expected: 1.25
case 2
in: [1,0.25,0.5]
expected: 0
case 3
in: [4,-2,1]
expected: -0.25
Starter codePython
def lasso_coordinate_step_scalar(a, b, lam):
    # Your code here
    pass

3 test cases · run your code against them in the editor