Question: 4 2 . We construct a function that realizes the sparse group Lasso. Fill in the blanks, and execute the procedure in Excercise 3 .

42. We construct a function that realizes the sparse group Lasso. Fill in the blanks, and execute the procedure in Excercise 3.8 to examine the validity.
```
def sparse_gr(x, y, lam, alpha):
p = X.shape [1]
nu =1/ np.max(np.11nalg.e1gvals(x.T ( x))
beta = np.zeros(p)
beta_old = np.zeros(p)
eps =1
while eps >0.001:
gamma = beta + nu * x.T (y - x 0 beta)
delta = soft_th(lan * alpha, gamma)
beta = np.zeros(p)
if np.l1nalg.norm(delta,2)>0:
beta - ## Blank(l) ##
eps = np.max(np.abs(beta - beta_old))
beta_old = copy.copy(beta)
return beta
```
```
def sparse_group_lasso(z, y,1am-0, alpha-0):
J - len(z)
theta -[]
for 1 in range(J):
theta.append (np. zeros(z[1].shape[1]))
for n in range(10):
for J in range(J):
r = copy .copy (y)
for k in range(J):
if k !- J:
r = r - z[k]0 theta[k]
theta[1]- ## Blank(2) ##
return theta
```
4 2 . We construct a function that realizes the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!