distance.py 文件源码

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

项目:ECoG-ClusterFlow 作者: sugeerth 项目源码 文件源码
def get_dist_func(name):
    """

    Valid names:
        Euclidean
        Pearson

    """

    if name == 'Euclidean':

        if EUC_C_EXT_ENABLED:
            return euclidean.euclidean
        else:
            return euc

    elif name == 'Pearson':

        #FIXME: Until I write my own c-extension, this is as good as it gets.  And it's SLOW.
        return lambda x, y: 1 - numpy.corrcoef(x,y)[0][1] #Again, we normalise -1 to distant and 1 to close. corrcoef returns the correlation matrix.

    else:

        raise ValueError, 'No distance function named: %s' % name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号