qmath.py 文件源码

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

项目:RecQ 作者: Coder-Yu 项目源码 文件源码
def cosine(x1,x2):
    #find common ratings
    #new_x1, new_x2 = common(x1,x2)
    #compute the cosine similarity between two vectors
    sum = x1.dot(x2)
    denom = sqrt(x1.dot(x1)*x2.dot(x2))
    try:
        return float(sum)/denom
    except ZeroDivisionError:
        return 0

    #return cosine_similarity(x1,x2)[0][0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号