fossil.py 文件源码

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

项目:sequence-based-recommendations 作者: rdevooght 项目源码 文件源码
def top_k_recommendations(self, sequence, user_id=None, k=10, exclude=None):
        ''' Recieves a sequence of (id, rating), and produces k recommendations (as a list of ids)
        '''

        if exclude is None:
            exclude = []

        user_items = [i[0] for i in sequence]
        output = self.item_score(user_id, user_items)

        # Put low similarity to viewed items to exclude them from recommendations
        output[[i[0] for i in sequence]] = -np.inf
        output[exclude] = -np.inf

        # find top k according to output
        return list(np.argpartition(-output, range(k))[:k])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号