Distance Metrics
1. 歐氏距離(Euclidean Distance)
定義:
Python 範例:
from scipy.spatial.distance import euclidean
x = [1, 2]
y = [4, 6]
print(euclidean(x, y)) # 輸出: 5.02. 曼哈頓距離(Manhattan Distance)
定義:
Python 範例:
3. 餘弦相似度/距離(Cosine Similarity / Distance)
相似度定義:
餘弦距離:
Python 範例:
4. 切比雪夫距離(Chebyshev Distance)
定義:
Python 範例:
5. 漢明距離(Hamming Distance)
Python 範例:
6. 距離選擇建議
應用場景
建議距離
Last updated