Distance Metric Learning for Kernel Machines

Zhixiang Eddie Xu, Kilian Q. Weinberger, Olivier ChapellearXiv 2012

Abstract

Recent work in metric learning has significantly improved the state-of-the-art in k-nearest neighbor classification. Support vector machines (SVM), particularly with RBF kernels, are amongst the most popular classification algorithms that uses distance metrics to compare examples. This paper provides an empirical analysis of the efficacy of three of the most popular Mahalanobis metric learning algorithms as pre-processing for SVM training. We show that none of these algorithms generate metrics that lead to particularly satisfying improvements for SVM-RBF classification. As a remedy we introduce support vector metric learning (SVML), a novel algorithm that seamlessly combines the learning of a Mahalanobis metric with the training of the RBF-SVM parameters. We demonstrate the capabilities of SVML on nine benchmark data sets of varying sizes and difficulties. In our study, SVML outperforms all alternative state-of-the-art metric learning algorithms in terms of accuracy and establishes itself as a serious alternative to the standard Euclidean metric with model selection by cross validation.

Introduction

Support Vector Machines (SVMs) using Radial Basis Function (RBF) kernels are a cornerstone of modern classification, relying heavily on distance metrics to determine sample similarity. Traditionally, the Euclidean distance is the default choice. However, supervised learning provides labels that define similarity in context. While Mahalanobis metric learning has significantly improved k-Nearest Neighbor (kNN) classifiers by warping feature spaces, these improvements do not always translate to SVMs.

This paper addresses a critical gap: kNN-optimized metrics (like LMNN, NCA, or ITML) often fail to improve the max-margin decision boundaries of SVMs. The authors propose a method to learn a distance metric explicitly tailored for the SVM classification rule.

Support Vector Metric Learning (SVML)

The proposed Support Vector Metric Learning (SVML) integrates metric learning directly into the SVM training process. Instead of a two-step approach, SVML learns a Mahalanobis transformation matrix $L$ that parameterizes the RBF kernel.

The objective is to minimize classification error on a hold-out validation set. Since the 0-1 loss is non-differentiable, SVML employs a smooth, differentiable surrogate function, $s_a(z)$, to enable gradient-based optimization.

The smooth surrogate loss function $s_a(z)$ used to approximate 0-1 loss for gradient descent.

By utilizing implicit differentiation and the properties of support vectors on the margin boundary, the authors compute the exact gradient of the validation loss with respect to $L$. This allows for various structural constraints, such as learning a scalar (kernel width tuning), a diagonal matrix (feature weighting), or a rectangular matrix (dimensionality reduction for visualization).

Experimental Evaluation

The authors evaluated SVML across nine UCI benchmark datasets, ranging from small survival studies to large telescope data. All tasks were framed as binary classification problems.

Summary of dataset statistics and baseline error rates for standard metric learning algorithms.

Key Results and Insights

The empirical analysis yielded several significant findings:

  • Superior Accuracy: SVML with a full Mahalanobis matrix achieved the best statistically significant results on 6 of the 9 datasets, outperforming both standard Euclidean SVMs and those pre-processed with kNN-based metrics.
  • kNN Metrics vs. SVMs: The study confirms that metrics optimized for local neighborhood votes (NCA, ITML, LMNN) do not reliably benefit the global max-margin hyperplanes of SVMs.
  • Efficiency: SVML eliminates the need for exhaustive grid-search cross-validation for hyperparameters like $\sigma$ and $C$. Its training time is comparable to standard SVM training with 3- to 5-fold cross-validation.
  • Interpretability: By projecting data into 2D or 3D spaces via a rectangular matrix $L$, SVML provides a powerful tool for visualizing non-linear decision boundaries in high-dimensional data.

Conclusion

SVML represents a robust alternative to standard Euclidean metrics and kNN-based pre-processing for SVMs. While currently focused on binary classification and subject to local minima due to non-convexity, its ability to learn task-specific metrics end-to-end makes it a valuable tool for practitioners. Future work includes extending the framework to multi-class classification and releasing an open-source LIBSVM plugin.

Summary updated

BibTeX
@misc{xu2012distance,
  author = {Zhixiang Eddie Xu and Kilian Q. Weinberger and Olivier Chapelle},
  title = {{Distance Metric Learning for Kernel Machines}},
  year = {2012},
  eprint = {1208.3422},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1208.3422},
}
Figure