Question: LETS PLOT THE COMPARISON [ ]: Stochastic Gradient Descent algorithm [56]: X_np = X. values Y_np = Y. values n,k=X_np . shape m=Y_np . shape[1]

LETS PLOT THE COMPARISON

[ ]: Stochastic Gradient Descent algorithm [56]: X_np = X. values Y_np = Y. values n,k=X_np . shape m=Y_np . shape[1] params=np . zeros ( (k,m) , dtype=float) sse={} for i in range(1, iters+1): Y_hat=x_np @ params grads=(X_np . T@(Y_hat-Y_np)) params-=lr*grads sse[i]=np. sum( (Y_np-Y_hat)**2) params_df = pd. DataFrame(params, index=X. columns, columns=Y. columns) [57]: params_df . round(6) [57] : Low Equity Medium Equity High Equity const 0.002829 0.001831 0.001398 SA Equity 0.167218 0.351015 0.437615 SA Bonds 0.075452 0.032487 0.019809 SA Property 0.055711 0.046449 0.045622 SA Cash 0.011567 0.010205 0.011823 Offshore Equity 0.087795 0.123234 0.138990 Offshore Bonds 0.032450 0.036426 0.043553 [59]: comparison=pd . concat([beta_cf, params_df], axis=1, keys=["Closed Form","SGD"]) [60]: comparison [60 ] : Closed Form SGD Low Equity Medium Equity High Equity Low Equity Medium Equity High Equity const -0.000350 -0.001181 -0.002121 0.002829 0.001831 0.001398 SA Equity 0.167747 0.353080 0.440542 0.167218 0.351015 0.437615 SA Bonds 0.080727 0.029612 0.013444 0.075452 0.032487 0.019809 SA Property 0.054168 0.046160 0.045769 0.055711 0.046449 0.045622 SA Cash 0.547691 0.525145 0.616062 0.011567 0.010205 0.011823

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 Mathematics Questions!