engine.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:TensorGlue 作者: Evfro 项目源码 文件源码
def svd_recommender(self):
        userid, itemid, contextid, values = self.fields
        test_idx = (self.test.testset[userid].values,
                    self.test.testset[itemid].values)
        if contextid:
            #TODO: refactor it! need to think about dependence on self.arrange_by and contextid
            #values are contextualized already
            test_val = self.test.testset[values].values
        else:
            test_val = self.test.testset[values].values

        v = self._items_factors
        test_shp = (self.test.testset[userid].max()+1,
                    v.shape[1])

        test_matrix = sp.sparse.coo_matrix((test_val, test_idx),
                                           shape=test_shp,
                                           dtype=np.float64).tocsr()

        svd_scores = (test_matrix.dot(v.T)).dot(v)
        return svd_scores
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号