Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def F(data,beta,lam = 0):
- n = data.count() # find the number of (x,y) pairs in data
- regMSE = (data.map(lambda (x,y): f(x, y, beta)).reduce(lambda x, y: x+y))/float(n) + lam*sum(beta**2)
- return regMSE
- def test(data,beta):
- m = data.count() # find the number of (x,y) pairs in testing data
- testMSE = (data.map(lambda (x,y): f(x,y,beta)).reduce(lambda x, y: x+y))/float(m)
- return testMSE
Advertisement
Add Comment
Please, Sign In to add comment