A metric learning perspective of SVM: on the relation of SVM and LMNN

Huyen Do, Alexandros Kalousis, Jun Wang, Adam Woznica

Abstract

Support Vector Machines (SVM) and Large Margin Nearest Neighbor (LMNN) are cornerstone algorithms in machine learning with seemingly distinct biases—global vs. local. This paper establishes a unified framework, demonstrating that SVM can be cast as a metric learning problem. We show that LMNN is equivalent to learning a set of local SVM-like models within a quadratic space. Furthermore, we introduce $\epsilon$-SVM, a novel variant inspired by this metric perspective that incorporates a penalty for within-class spread. Empirical results across benchmark datasets indicate that $\epsilon$-SVM often outperforms both standard SVM and LMNN.

Introduction

In classification, SVMs are typically viewed as global models seeking a maximum-margin hyperplane to separate classes. Conversely, LMNN is a local approach that learns a Mahalanobis distance metric to ensure a point's $k$-nearest neighbors belong to the same class. While both utilize hinge loss and margin concepts, their relationship has historically been considered superficial. This work aims to bridge this gap, providing a deeper theoretical connection that allows for cross-pollination between these two paradigms.

The Metric Learning Perspective of SVM

The standard SVM formulation involves finding a hyperplane that maximizes the margin $\gamma$ relative to the data radius $R$. We propose a shift in perspective: instead of moving the hyperplane in a fixed space, we fix the hyperplane and transform the underlying data space.

Geometric interpretation of the radius-margin relationship in SVM.

By warping the space using a diagonal transformation matrix, we prove that this metric learning approach is mathematically equivalent to the traditional SVM. This insight leads to the development of $\epsilon$-SVM. Unlike standard SVMs that only penalize points violating the margin, $\epsilon$-SVM introduces a penalty for points that are excessively distant from the hyperplane, effectively minimizing within-class variance—a core objective in metric learning.

Unifying LMNN and SVM

The most significant contribution of this work is the demonstration that LMNN can be re-interpreted as an ensemble of local SVMs. By mapping data into a higher-dimensional quadratic space, the Mahalanobis distance becomes linear. In this space, the LMNN objective function transforms into a collection of $n$ local $\epsilon$-SVM models, one centered around each data point.

Comparison of LMNN viewed as local SVM-like models (a) versus a global SVM metric learning perspective (b).

This "local-to-global" mapping reveals that LMNN is not merely similar to SVM; it is a localized application of the same fundamental principles. This unified view suggests that $\epsilon$-SVM serves as a computationally efficient proxy for the theoretically ideal but complex radius-margin bound.

Experimental Evaluation

We evaluated $\epsilon$-SVM against standard SVM and LMNN using ten benchmark datasets from the UCI Repository, covering medical (e.g., breast cancer, leukemia) and physical (e.g., sonar, ionosphere) domains. Experiments utilized 10-fold cross-validation across linear, polynomial, and Gaussian kernels.

Key findings include:

  • Performance: $\epsilon$-SVM achieved lower error rates than standard SVM in 19 of 40 experimental runs and outperformed LMNN in 20 cases.
  • Statistical Significance: Using the McNemar test, $\epsilon$-SVM (46 points) demonstrated clear superiority over SVM (37.5) and LMNN (36.5).
  • Kernel Synergy: The advantages of $\epsilon$-SVM were most pronounced with Gaussian kernels, where its inherent regularization helps manage high-dimensional feature spaces.

Conclusion

By reframing SVM as a metric learning problem, we have uncovered a deep mathematical link between global margin maximization and local distance metric learning. The resulting $\epsilon$-SVM variant provides a robust middle ground that leverages the strengths of both approaches. Future work will focus on extending this framework to multiclass classification and addressing the computational challenges of large-scale implementations.

Summary updated

Abstract

Support Vector Machines, SVMs, and the Large Margin Nearest Neighbor algorithm, LMNN, are two very popular learning algorithms with quite different learning biases. In this paper we bring them into a unified view and show that they have a much stronger relation than what is commonly thought. We analyze SVMs from a metric learning perspective and cast them as a metric learning problem, a view which helps us uncover the relations of the two algorithms. We show that LMNN can be seen as learning a set of local SVM-like models in a quadratic space. Along the way and inspired by the metric-based interpretation of SVM s we derive a novel variant of SVMs, epsilon-SVM, to which LMNN is even more similar. We give a unified view of LMNN and the different SVM variants. Finally we provide some preliminary experiments on a number of benchmark datasets in which show that epsilon-SVM compares favorably both with respect to LMNN and SVM.
BibTeX
@inproceedings{do2012metric,
  author = {Huyen Do and Alexandros Kalousis and Jun Wang and Adam Woznica},
  title = {{A metric learning perspective of SVM: on the relation of SVM and LMNN}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2012},
  url = {https://openreview.net/forum?id=ZHjxWJffkwF},
}
Figure