d3d550a6e4fe4a49205f0375f8d5a520f75d7423,algorithm/rating/EE.py,EE,buildModel,#EE#,22

Before Change


                u = self.dao.user[user]
                i = self.dao.item[item]
                self.loss += error ** 2
                self.loss += self.regU * (self.X[u] - self.Y[i]).dot(self.X[u] - self.Y[i])
                bu = self.Bu[u]
                bi = self.Bi[i]
                //self.loss += self.regB * bu ** 2 + self.regB * bi ** 2
                // update latent vectors
                self.X[u] -= self.lRate * (error + self.regU) * (self.X[u] - self.Y[i])
                self.Y[i] += self.lRate * (error + self.regI) * (self.X[u] - self.Y[i])
                self.Bu[u] += self.lRate * (error - self.regB * bu)
                self.Bi[i] += self.lRate * (error - self.regB * bi)
            self.loss+=self.penaltyLoss()
            iteration += 1
            self.isConverged(iteration)

    def predict(self, u, i):

After Change


        self.X = np.random.rand(self.dao.trainingSize()[0], self.Dim)/10
        self.Y = np.random.rand(self.dao.trainingSize()[1], self.Dim)/10

    def buildModel(self):
        iteration = 0
        while iteration < self.maxIter:
            self.loss = 0
            for entry in self.dao.trainingData:
                user, item, rating = entry
                error = rating - self.predict(user,item)
                u = self.dao.user[user]
                i = self.dao.item[item]
                self.loss += error ** 2
                self.loss += self.regU * (self.X[u] - self.Y[i]).dot(self.X[u] - self.Y[i])
                bu = self.Bu[u]
                bi = self.Bi[i]
                //self.loss += self.regB * bu ** 2 + self.regB * bi ** 2
                // update latent vectors
                self.X[u] -= self.lRate * (error + self.regU) * (self.X[u] - self.Y[i])
                self.Y[i] += self.lRate * (error + self.regI) * (self.X[u] - self.Y[i])
                self.Bu[u] += self.lRate * (error - self.regB * bu)
                self.Bi[i] += self.lRate * (error - self.regB * bi)
            self.loss+=self.regB*(self.Bu*self.Bu).sum()+self.regB*(self.Bi*self.Bi).sum()
            iteration += 1
            self.isConverged(iteration)

    def predict(self, u, i):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 17

Instances


Project Name: Coder-Yu/RecQ
Commit Name: d3d550a6e4fe4a49205f0375f8d5a520f75d7423
Time: 2017-06-21
Author: coderyy@outlook.com
File Name: algorithm/rating/EE.py
Class Name: EE
Method Name: buildModel


Project Name: Coder-Yu/RecQ
Commit Name: d3d550a6e4fe4a49205f0375f8d5a520f75d7423
Time: 2017-06-21
Author: coderyy@outlook.com
File Name: algorithm/rating/PMF.py
Class Name: PMF
Method Name: buildModel


Project Name: Coder-Yu/RecQ
Commit Name: d3d550a6e4fe4a49205f0375f8d5a520f75d7423
Time: 2017-06-21
Author: coderyy@outlook.com
File Name: algorithm/rating/SVD.py
Class Name: SVD
Method Name: buildModel


Project Name: Coder-Yu/RecQ
Commit Name: d3d550a6e4fe4a49205f0375f8d5a520f75d7423
Time: 2017-06-21
Author: coderyy@outlook.com
File Name: algorithm/rating/EE.py
Class Name: EE
Method Name: buildModel