Distance learning naturally breaks up into some distinct categories.
If \(M=\mathbb {R}^p\)  and that latter function \(\phi \)  is required to be linear, then \(d_2\)  is necessary a Mahalanobis distance function, of the form \(d_2(x,y)=(x-y)^TM(x-y)\)  for some symmetric positive-semidefinite \((n\times n)\) -matrix \(M\) ; in the case learning \(d_2\)  amounts to learning a symmetric positive-semidefinite \((n\times n)\) -matrix which satisfies some given criteria.
If \(M\)  is a non-compact Riemannian manifold and \(\phi \)  is an open smooth immersion, then \(d_2\)  can be indirectly learned by first learning the Riemannian metric on \(M\)  [1]}.
If \(M\)  is some infinite dimensional Hilbert space and \(\phi \)  is nonlinear, then \(d_2\)  can often be expressed in terms of a kernel.
If \(M\)  is some \(q\) -manifold for \(q\ll p\) , then learning a function \(\phi \)  that minimizes some distortion between \(d_1\)  and \(d_2\)  is often called dimensionality reduction [2]}.
Conversely, many dimensionality reduction algorithms for finding some optimal \(\phi \)  are, or at least can be, obtained by first learning the distance \(d_2\)  and obtaining an eigendecomposition to a matrix whose \((i,j)\) th entry is a function of \(\mathrm {dist}_M(x_i,x_j)\)  [3]}, [4]}.
