Source-linked AI summary

Metric distances derived from cosine similarity and Pearson and Spearman correlations

Stijn van Dongen, Anton J. Enright

arXiv:1208.3145v1stat.MEcs.LG

TL;DR

Cosine similarity and Pearson and Spearman correlations need metric-distance transforms when dissimilarities must obey the triangle inequality. The paper derives two classes of such transforms, using metric-preserving functions and properties of angular distance. The resulting distances either place anti-correlated objects maximally far apart or collate correlated and anti-correlated objects.

  • Problem

    Dissimilarities such as 1−A do not guarantee the triangle inequality, although metric distances are useful for methods that rely on it.

    Source: §2 · p. 2, §4 · p. 3
  • Method

    The paper derives transforms of cosine similarity and Pearson and Spearman correlations using metric-preserving functions and properties of angular distance.

    Source: §1 · p. 1, §3 · p. 3, §4 · p. 4
  • Results

    The transforms yield metric distances that either place anti-correlated objects maximally far apart or collate correlated and anti-correlated objects.

    Source: §1 · p. 1, §4 · pp. 3–4
  • Takeaways & Limitations

    These metric distances satisfy the triangle inequality, which supports applications such as M-tree construction and accelerated algorithms that skip computations using bounds.

    Source: §2 · p. 2, §4 · p. 3

Abstract

from arXiv · show

We investigate two classes of transformations of cosine similarity and Pearson and Spearman correlations into metric distances, utilising the simple tool of metric-preserving functions. The first class puts anti-correlated objects maximally far apart. Previously known transforms fall within this class. The second class collates correlated and anti-correlated objects. An example of such a transformation that yields a metric distance is the sine function when applied to centered data.

1. Results

The results derive metric distances from cosine similarity and Pearson and Spearman correlations in two classes: one places anti-correlated objects maximally far apart, while the other collates correlated and anti-correlated objects.

1. Results

  • The angular distance arccos(A(x, y)) is a known metric transform of cosine similarity and Pearson and Spearman correlations.Source: §1 · p. 1
  • The correlation distance is another transform that places anti-correlated objects maximally far apart.The passage gives it as sin(θ/2), or equivalently a square-root expression in A(x, y).Source: §1 · p. 1
  • A second class collates correlated and anti-correlated objects, with acute angular distance and absolute correlation distance as examples.Source: §1 · p. 1

2. Background

Pearson and Spearman correlations measure association, while cosine similarity measures the angle between vectors; the paper relates these measures and motivates metric distances by their triangle inequality.

2. Background

  • Pearson and Spearman coefficients measure association between variables, and Pearson is covariance divided by the product of their standard deviations.Source: §2 · p. 1
  • Spearman correlation applies the Pearson coefficient to rank-transformed data, while Pearson, Spearman, and cosine similarity are unaffected by linear transformations of the data.Source: §2 · p. 1
  • Cosine similarity is the cosine of the angle between Euclidean vectors and is unaffected by scalar transformations.Source: §2 · pp. 1–2
  • Pearson is identical to cosine similarity applied to centered data, and the paper treats vectors and samples interchangeably.Source: §2 · p. 2
  • Metric distances are desirable for dissimilarities because the triangle inequality supports M-tree construction and accelerated algorithms that skip computations using bounds.Source: §2 · p. 2

3. Metric distances

The section uses metric-preserving functions to transform distances, focusing on increasing concave functions and showing how concavity supplies the subadditivity needed for metric preservation.

3. Metric distances

  • A metric distance is nonnegative, symmetric, zero for identical objects only, and satisfies the triangle inequality.Source: §3 · p. 2
  • A metric-preserving function transforms any metric distance into another metric, and increasing concave functions with f(0)=0 form a useful sufficient subclass.Source: §3 · pp. 2–3
  • Concavity with f(0)≥0 yields subadditivity, which is the key property used to show that the transformed distance satisfies the triangle inequality.Source: §3 · p. 3
  • For a twice-differentiable function, f''(x)≤0 on an interval implies concavity there, and an increasing function with this property for x>0 and f(0)=0 is metric-preserving.Source: §3 · p. 3

4. From correlations to distances

The section derives metric distances from Pearson, Spearman, and cosine similarity, including transforms that keep anti-correlated objects far apart and transforms that collate them. It uses the angular distance as a basis for these constructions and shows why the natural dissimilarity 1 − A need not be metric.

4. From correlations to distances

  • The natural dissimilarity 1 − A can violate the triangle inequality, despite satisfying the other metric properties.A function increasing and strictly convex near zero, including 1 − A, yields a dissimilarity that violates the triangle inequality.Source: §4 · pp. 3–5
  • The angular distance arccos(A(x, y)) is metric for A equal to Pearson, Spearman, or cosine similarity.Here A denotes any of those three measures.Source: §4 · p. 3
  • The symmetric class includes acute angular distance and absolute correlation distance, which collate correlated and anti-correlated objects.The sine of angular distance is another example; sin(θ/2) is metric-preserving for angular distance, but not in general.Source: §4 · p. 4
  • Increasing, concave functions of angular distance that vanish at zero yield metric-preserving distances; symmetric functions can also collate a vector with its sign-reversed counterpart.For the symmetric case, directionality is disregarded and a vector and its sign-reversed counterpart are treated as one object.Source: §4 · pp. 4–5
  • The first class defines angular distance as arccos(A(x, y)) and correlation distance as 1/2(1 − A(x, y)), with A denoting any of P, S, or C.Source: §4 · p. 4

5. Notes

Composing concave functions yields further metric distances, including sin(x)^p for 0 < p ≤ 1; these preserve rankings of distances relative to the absolute correlation distance.

5. Notes

  • Compositions such as sin(x)^p, for 0 < p ≤ 1, yield further distances ordinally equivalent to absolute correlation distance and preserve distance rankings.Source: §5 · p. 5
Loading 1208.3145v1…