Author: Not specified Language: python
Description: Not specified Timestamp: 2018-06-11 02:56:38 +0000
View raw paste Reply
  1. def minimum_m():
  2.     mse_list = []
  3.     for m in range(1,10):
  4.         phi = draw_phi(m)
  5.         y = np.matmul(phi,np.transpose(x))/(math.sqrt(m))
  6.         B = np.transpose(u)
  7.         matrix = np.matmul(phi,B)
  8.         clf = linear_model.Lasso(alpha=1.0)
  9.         clf.fit(matrix,y)
  10.         a_hat = clf.coef_
  11.         s_hat = np.matmul(a_hat,np.transpose(B))
  12.         mean_square_error = np.linalg.norm(s_hat - s)/np.linalg.norm(s)
  13.         mse_list.append(mean_square_error)
  14.     plt.plot(list(range(1,10)), mse_list)
  15.     plt.show()
  16.     return np.argmin(mse_list)+1
View raw paste Reply