Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. X = np.array([[0],[1],[2],[4]])
  2. y = np.array([4,1,2,5])
  3.  
  4. poly = sklearn.preprocessing.PolynomialFeatures(3)
  5. Omega = poly.fit_transform(X)
  6. weights = {}
  7. print(Omega.shape[0])
  8. reg_fact = [0, 1, 10]
  9. for i in reg_fact:
  10.     weights['reg_fact={}'.format(i)] = la.multi_dot([la.inv(np.dot(Omega.T,Omega) + np.multiply(i, np.identity(Omega.shape[0]))), Omega.T, y])
  11. print(weights)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement