Large Margin Nearest Neighbor Classification using Curved Mahalanobis Distances

Frank Nielsen, Boris Muzellec, Richard NockarXiv 2016

Abstract: We consider the supervised classification problem of machine learning in Cayley-Klein projective geometries: We show how to learn a curved Mahalanobis metric distance corresponding to either the hyperbolic geometry or the elliptic geometry using the Large Margin Nearest Neighbor (LMNN) framework. We report on our experimental results, and further consider the case of learning a mixed curved Mahalanobis distance. Besides, we show that the Cayley-Klein Voronoi diagrams are affine, and can be built from an equivalent (clipped) power diagrams, and that Cayley-Klein balls have Mahalanobis shapes with displaced centers.

Introduction

Most machine learning algorithms operate under the assumption of a "flat" Euclidean space. While Mahalanobis distances allow for stretching and rotating this space to better group similar points, they fail to capture the intrinsic curvature often present in real-world data manifolds. Non-Euclidean geometries, such as hyperbolic or elliptic spaces, offer a more natural representation for hierarchical or spherical data, yet they are frequently perceived as computationally prohibitive.

This paper bridges this gap by extending the Large Margin Nearest Neighbor (LMNN) framework—a cornerstone of supervised metric learning—into Cayley-Klein (CK) projective geometries. By reinterpreting CK distances as "curved Mahalanobis distances," the authors provide a method to learn the underlying curvature of data while maintaining the efficiency of linear decision boundaries.

Methodology: Learning Curved Metrics

The core contribution is the adaptation of LMNN to non-Euclidean spaces through several key innovations.

Curved Mahalanobis Distances

The authors define elliptic (positive curvature) and hyperbolic (negative curvature) distances using a bilinear form. These metrics are designed to gracefully collapse into the standard Mahalanobis distance as the curvature parameter approaches zero.

Distance and angle measurements in Cayley-Klein geometry.

As shown in Figure 6, distances and angles in these geometries are defined via cross-ratios involving points on a fundamental conic $\mathcal{F}$. Specifically, the distance between two points $p$ and $q$ is proportional to the logarithm of their cross-ratio with the intersection points $P$ and $Q$ on the conic.

The CK-LMNN Algorithm

The authors derive gradients for the LMNN cost function—comprising "pull" and "push" losses—optimized for these curved distances. Given the non-convex nature of these loss functions, the paper proposes initialization strategies based on sample mean and covariance to avoid poor local minima.

Mixed Geometries and Affine Properties

A novel "linearly mixed Cayley-Klein distance" is introduced, blending elliptic and hyperbolic components to adapt to complex data manifolds. Crucially, the authors prove that Cayley-Klein Voronoi diagrams remain affine. This ensures that decision boundaries are hyperplanes, allowing for efficient nearest-neighbor queries using standard data structures despite the underlying "curved" distance metric.

Experimental Evaluation

The approach was evaluated on several UCI Machine Learning Repository datasets, including Wine, Sonar, Vowel, Balance, and Pima.

Key Results

  • Performance Gains: The Elliptic CK-LMNN frequently outperformed standard Mahalanobis LMNN. On the Wine dataset ($k=11$), the Elliptic model achieved an accuracy of 0.994, surpassing the standard model's 0.984.
  • The Mixed Model Advantage: Blending geometries often yielded the best results. On the Sonar dataset, the Mixed model reached 0.802 accuracy, significantly higher than standard Mahalanobis (0.733) or pure Hyperbolic (0.640) variants.
  • Anisotropy: Unlike standard Mahalanobis space where "balls" have constant shapes, CK geometry balls are anisotropic. Their shape and orientation change based on their location, allowing the model to adapt to local data density variations.

Discussion and Conclusion

The "affine surprise"—that curved distances can still yield flat decision frontiers—is a significant finding for practical machine learning. It allows for the expressive power of non-Euclidean geometry without the typical computational overhead.

However, the non-convexity of the loss function makes the algorithm sensitive to initialization. Future work may explore extending this "curved" logic to other algorithms like Support Vector Machines (SVMs) or Multi-Dimensional Scaling (MDS), and further investigating the role of these metrics in anisotropic mesh generation. By treating curvature as a learnable feature, this framework moves metric learning closer to capturing the true "shape" of data.

Summary updated

BibTeX
@misc{nielsen2016large,
  author = {Frank Nielsen and Boris Muzellec and Richard Nock},
  title = {{Large Margin Nearest Neighbor Classification using Curved Mahalanobis Distances}},
  year = {2016},
  eprint = {1609.07082},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1609.07082},
}
Figure