Question: 4 2 . We construct a function that realizes the sparse group Lasso. Fill in the blanks, and execute the procedure in Excercise 3 .
We construct a function that realizes the sparse group Lasso. Fill in the blanks, and execute the procedure in Excercise to examine the validity.
def sparsegrx y lam, alpha:
p Xshape
nu npmaxnpnalg.egvalsxT x
beta npzerosp
betaold npzerosp
eps
while eps :
gamma beta nu xT y x beta
delta softthlan alpha, gamma
beta npzerosp
if nplnalg.normdelta:
beta ## Blankl ##
eps npmaxnpabsbeta betaold
betaold copy.copybeta
return beta
def sparsegrouplassoz yam alpha:
J lenz
theta
for in rangeJ:
theta.append np zeroszshape
for n in range:
for J in rangeJ:
r copy copy y
for k in rangeJ:
if k J:
r r zk thetak
theta ## Blank ##
return theta
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
