MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / get_loss

Function get_loss

recommenders/mf.py:55–63  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

53# prediction[i,j] = W[i].dot(U[j]) + b[i] + c.T[j] + mu
54
55def get_loss(d):
56 # d: (user_id, movie_id) -> rating
57 N = float(len(d))
58 sse = 0
59 for k, r in d.items():
60 i, j = k
61 p = W[i].dot(U[j]) + b[i] + c[j] + mu
62 sse += (p - r)*(p - r)
63 return sse / N
64
65
66# train the parameters

Callers 1

mf.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected