Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-114

Sparse Group Lasso Step

Problem

Apply the sparse group lasso proximal operator to a coefficient vector.

First treat the whole vector as a group and soft-threshold it at lam2 (scale by 1 - lam2 / ||x||, or zero it when ||x|| <= lam2). Then apply elementwise soft thresholding at lam1. Return the result.

Hint

Group shrinkage runs first, then the elementwise L1 shrinkage.

Test cases

case 1
in: [[3,4],0.5,1]
expected: [1.9000000000000004,2.7]
case 2
in: [[0.1,0.2],0.05,1]
expected: [0,0]
case 3
in: [[10,0],1,2]
expected: [7,0]
case 4
in: [[5],6,1]
expected: [0]
Starter codePython
def sparse_group_lasso_step(x, lam1, lam2):
    # Your code here
    pass

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