Sparse Compositional Metric Learning

Yuan Shi, Aurélien Bellet, Fei Sha

In many machine learning tasks, the choice of distance metric is fundamental to performance. While the Euclidean distance is a standard baseline, it often fails to account for the underlying structure of high-dimensional data. Metric learning aims to address this by learning a Mahalanobis distance $d_M(x, x') = \sqrt{(x-x')^T M (x-x')}$ where $M$ is a positive semi-definite (PSD) matrix. However, traditional approaches face significant challenges: the $O(D^3)$ cost of PSD projections and the difficulty of balancing global consistency with local adaptability.

In their paper, "Sparse Compositional Metric Learning," Yuan Shi, Aurélien Bellet, and Fei Sha propose a novel framework that bypasses these hurdles by treating metric learning as a "composition" problem.

The SCML Framework

The core innovation of Sparse Compositional Metric Learning (SCML) is the representation of the metric matrix $M$ as a sparse, non-negative linear combination of rank-1 basis elements: $$M = \sum_{i=1}^{K} w_i b_i b_i^T$$ where $w_i \ge 0$. This formulation ensures that $M$ is PSD by construction, provided the bases $b_i b_i^T$ are themselves PSD. This design choice is critical as it completely removes the need for expensive matrix projections during the optimization process, allowing for the use of fast stochastic subgradient descent.

Overview of the SCML framework showing basis extraction and the three learning variants.

The process begins with the extraction of a library of "basis metrics." Rather than using random bases, the authors employ Fisher Discriminant Analysis (FDA) on local clusters of the training data. These bases capture locally discriminative directions that are likely to be useful for classification. By applying sparsity-inducing regularizers, such as the $\ell_1$ norm, the algorithm learns to select only a small, relevant subset of these bases from the library.

Variants of SCML

The SCML framework is highly flexible and can be adapted to different learning scenarios:

  • SCML-Global: This variant learns a single sparse weight vector $w$ for the entire dataset. It is particularly effective for high-dimensional data where traditional global metric learning methods struggle with computational overhead.
  • Multi-task SCML (mt-SCML): In multi-task settings, mt-SCML learns distinct metrics for related tasks while forcing them to share the same underlying subset of basis elements. This promotes knowledge transfer and improves generalization, as demonstrated in the authors' experiments on sentiment analysis across different product categories.
  • SCML-Local: This is perhaps the most innovative variant. It learns a function $\mathcal{T}(x)$ that maps a data point to a specific weight vector $w_x$. This creates a "smoothly varying" metric across the feature space, allowing the distance measure to adapt naturally as one moves from one region of the data to another. Unlike previous local metric learning methods, SCML-Local provides a principled way to compute distances for brand-new test points.

Experimental Evaluation

The authors evaluated SCML across a diverse set of benchmarks, including UCI repository datasets (Vehicle, Vowel, Segment, Letters), handwritten digits (USPS), and high-dimensional text data (BBC).

Comparison of classification error rates across various datasets.

As shown in the results table, SCML-Global consistently matched or exceeded the performance of state-of-the-art methods like LMNN and BoostML. On the high-dimensional BBC dataset, which contains nearly 10,000 features, SCML-Global was 20x to 35x faster than its competitors while maintaining higher accuracy.

The local variant, SCML-Local, also showed strong results, achieving the best average rank among all local metric learning methods tested. Interestingly, it proved to be highly competitive with Kernel SVMs, suggesting that a well-learned local metric combined with a simple k-nearest neighbor classifier is a powerful alternative to complex non-linear models.

Conclusion

SCML offers a scalable and efficient alternative to traditional metric learning. By leveraging sparsity and basis composition, it avoids the computational bottlenecks of PSD projections while providing a robust mechanism for both global and local distance adaptation. While the non-convexity of the local formulation remains a challenge, the framework's ability to handle high-dimensional data and generalize to unseen points makes it a significant contribution to the field of distance metric learning.

Summary updated

BibTeX
@inproceedings{shi2014sparse,
  author = {Yuan Shi and Aurélien Bellet and Fei Sha},
  title = {{Sparse Compositional Metric Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2014},
  doi = {10.1609/aaai.v28i1.8968},
}
Figure