def getNui(self):
# Generates Users who are trusted by user u and have rated product i
sz = len(self.R_train_ui) + len(self.R_test_ui)
for u, i in self.R_train_ui:
# Users who have rated product i
rat_u = self.R_train[np.where(self.R_train[:, 1] == i), 0]
# Users trusted by u
trust_u = self.W[np.where(self.W[:, 0] == u),1]
self.V[u, i] = np.intersect1d(rat_u, trust_u)
print u,i,self.V[u, i]
for u, i in self.R_test_ui:
# Users who have rated product i
rat_u = self.R_train[np.where(self.R_train[:, 1] == i), 0]
# Users trusted by u
trust_u = self.W[np.where(self.W[:, 0] == u),1]
self.V[u, i] = np.intersect1d(rat_u, trust_u)
print u,i,self.V[u, i]
model2.py 文件源码
python
阅读 34
收藏 0
点赞 0
评论 0
评论列表
文章目录