本文整理匯總了Python中scipy.spatial.distance.chebyshev方法的典型用法代碼示例。如果您正苦於以下問題:Python distance.chebyshev方法的具體用法?Python distance.chebyshev怎麽用?Python distance.chebyshev使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.spatial.distance
的用法示例。
在下文中一共展示了distance.chebyshev方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_distance_function
# 需要導入模塊: from scipy.spatial import distance [as 別名]
# 或者: from scipy.spatial.distance import chebyshev [as 別名]
def get_distance_function(requested_metric):
"""
This function returns a specified distance function.
Paramters
---------
requested_metric: str
Distance function. Can be any function in: https://docs.scipy.org/doc/scipy/reference/spatial.distance.html.
Returns
-------
requested_metric : distance function
"""
distance_options = {
'braycurtis': distance.braycurtis,
'canberra': distance.canberra,
'chebyshev': distance.chebyshev,
'cityblock': distance.cityblock,
'correlation': distance.correlation,
'cosine': distance.cosine,
'euclidean': distance.euclidean,
'sqeuclidean': distance.sqeuclidean,
'dice': distance.dice,
'hamming': distance.hamming,
'jaccard': distance.jaccard,
'kulsinski': distance.kulsinski,
'matching': distance.matching,
'rogerstanimoto': distance.rogerstanimoto,
'russellrao': distance.russellrao,
'sokalmichener': distance.sokalmichener,
'sokalsneath': distance.sokalsneath,
'yule': distance.yule,
}
if requested_metric in distance_options:
return distance_options[requested_metric]
else:
raise ValueError('Distance function cannot be found.')