/distance-metric-learning

Compilation of distance measures in Python

Primary LanguagePython

Distance Metric Learning

Compilation of distance measures in Python.

Libraries

List of Distances

  • Sum of Absolute Difference
  • Sum of Squared Difference
  • Mean Absolute Error
  • Mean Squared Error
  • Euclidean Distance
  • Chebyshev distance
  • Minkowski Distance
  • Canberra Distance
  • Cosine Distance
  • Pearson's Distance
  • Hamming Distance

Distances

Sum of Absolute Differences (SAD)

  • L1-norm
  • Manhattan- or Taxicab-norm
  • Minkowski distance with p=1
  • Formula: ∑ |pi - qi|
  • Code: SAD.py

Mean Absolute Error (MAE)

  • 1/n * Sum of Absolute Difference
  • Formula: 1n * ∑ |pi - qi|
  • Code: MAE.py

Sum of Squared Differences (SSD)

  • Squared L2-norm
  • Euclidean norm
  • Squared Euclidean distance
  • Formula: ∑ |pi - qi|2
  • Code: SSD.py

Mean Squared Error (MSE)

  • 1/n * Sum of Squared Difference
  • Formula: 1n * ∑ |pi - qi|2
  • Code: MSE.py

Euclidean Distance

  • L2-norm
  • Natural distance in a geometric interpretation
  • Formula: √ ∑ |pi - qi|2
  • Code: Euclidean.py

Chebyshev Distance

  • L-infinity norm
  • Minkowski distance with p=infinity
  • Formula: max |pi - qi|
  • Code: Chebyshev.py

Minkowski Distance

  • Lp-norm

Canberra Distance

  • Weighted Manhattan distance

Cosine Distance

  • Dot product scaled by product of Euclidean distances from the origin
  • Represents angular distance of 2 vectors, ignoring scale

Pearson's Distance

  • Correlation distance based on Pearson's product-momentum correlation coefficient of 2 sample vectors
  • Measures linear relationship between 2 vectors

Hamming Distance

  • No. of entries in 2 vectors which are different