def updateParameters(self, articlePicked_FeatureVector, click): additionalFeatureVector = vectorize( np.outer(self.userFeature, articlePicked_FeatureVector)) LinUCBUserStruct.updateParameters(self, articlePicked_FeatureVector, click) self.B += np.outer(articlePicked_FeatureVector, additionalFeatureVector)
def getProb(self, alpha, article_FeatureVector,userID): x = article_FeatureVector z = vectorize(np.outer(self.users[userID].userFeature, article_FeatureVector)) temp =np.dot(np.dot(np.dot( self.A_zInv , np.transpose( self.users[userID].B)) , self.users[userID].AInv), x ) mean = np.dot(self.users[userID].UserTheta, x)+ np.dot(self.beta, z) s_t = np.dot(np.dot(z, self.A_zInv), z) + np.dot(np.dot(x, self.users[userID].AInv), x) -2* np.dot(z, temp)+ np.dot(np.dot( np.dot(x, self.users[userID].AInv) , self.users[userID].B ) ,temp) var = np.sqrt(s_t) pta = mean + alpha * var return pta
def getProb(self, alpha, article_FeatureVector, userID): x = article_FeatureVector z = vectorize( np.outer(self.users[userID].userFeature, article_FeatureVector)) temp = np.dot( np.dot(np.dot(self.A_zInv, np.transpose(self.users[userID].B)), self.users[userID].AInv), x) mean = np.dot(self.users[userID].UserTheta, x) + np.dot(self.beta, z) s_t = np.dot(np.dot(z, self.A_zInv), z) + np.dot( np.dot(x, self.users[userID].AInv), x) -2 * np.dot(z, temp) + np.dot( np.dot(np.dot(x, self.users[userID].AInv), self.users[userID].B), temp) var = np.sqrt(s_t) pta = mean + alpha * var return pta
def updateParameters(self, articlePicked_FeatureVector, click, userID): z = vectorize( np.outer(self.users[userID].userFeature, articlePicked_FeatureVector)) temp = np.dot(np.transpose(self.users[userID].B), self.users[userID].AInv) self.A_z += np.dot(temp, self.users[userID].B) self.b_z +=np.dot(temp, self.users[userID].b) self.users[userID].updateParameters(articlePicked_FeatureVector, click) temp = np.dot(np.transpose(self.users[userID].B), self.users[userID].AInv) self.A_z = self.A_z + np.outer(z,z) - np.dot(temp, self.users[userID].B) self.b_z =self.b_z+ click*z - np.dot(temp, self.users[userID].b) self.A_zInv = np.linalg.inv(self.A_z) self.beta =np.dot(self.A_zInv, self.b_z) self.users[userID].updateTheta(self.beta)
def updateParameters(self, articlePicked_FeatureVector, click, userID): z = vectorize( np.outer(self.users[userID].userFeature, articlePicked_FeatureVector)) temp = np.dot(np.transpose(self.users[userID].B), self.users[userID].AInv) self.A_z += np.dot(temp, self.users[userID].B) self.b_z += np.dot(temp, self.users[userID].b) self.users[userID].updateParameters(articlePicked_FeatureVector, click) temp = np.dot(np.transpose(self.users[userID].B), self.users[userID].AInv) self.A_z = self.A_z + np.outer(z, z) - np.dot(temp, self.users[userID].B) self.b_z = self.b_z + click * z - np.dot(temp, self.users[userID].b) self.A_zInv = np.linalg.inv(self.A_z) self.beta = np.dot(self.A_zInv, self.b_z) self.users[userID].updateTheta(self.beta)
def updateParameters(self, article_FeatureVector, click): additionalFeatureVector = vectorize(np.outer(self.userFeature, article_FeatureVector)) LinUCBUserStruct.updateParameters(self, article_FeatureVector, click) self.B +=np.outer(article_FeatureVector, additionalFeatureVector)