word_distance.py 文件源码

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

项目:alfpy 作者: aziele 项目源码 文件源码
def pwdist_canberra(self, seq1idx, seq2idx):
        """Compute the Canberra distance between two vectors.

        References:
            1. http://scipy.org/

        Notes:
            When `u[i]` and `v[i]` are 0 for given i, then
            the fraction 0/0 = 0 is used in the calculation.
        """
        u = self[seq1idx]
        v = self[seq2idx]
        olderr = np.seterr(invalid='ignore')
        try:
            d = np.nansum(abs(u - v) / (abs(u) + abs(v)))
        finally:
            np.seterr(**olderr)
        return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号