for triple in self.dao.triple:
u,i,r = triple
u = self.dao.user[u]
i = self.dao.item[i]
error = r-self.P[u].dot(self.Q[i])-self.dao.globalMean-self.Bi[i]-self.Bu[u]
self.loss+=error**2
//update latent vectors
p = self.P[u].copy()
After Change
for triple in self.dao.triple:
u,i,r = triple
u = self.dao.getUserId(u)
i = self.dao.getItemId(i)
error = r-self.P[u].dot(self.Q[i])-self.dao.globalMean-self.Bi[i]-self.Bu[u]
self.loss+=error**2
p = self.P[u].copy()
q = self.Q[i].copy()
self.loss += self.regU * p.dot(p) + self.regI * q.dot(q)
bu = self.Bu[u]
bi = self.Bi[i]
self.loss += self.regB*bu**2 + self.regB*bi**2
//update latent vectors