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
评论列表
文章目录