Online Metric Learning
Online Metric Learning (Incremental Distance Metric Learning from Streaming Data) · Also known as: OML, incremental metric learning, streaming metric learning, online distance metric learning
Online Metric Learning adapts a Mahalanobis distance metric incrementally as new labeled examples or pairwise constraints arrive one at a time, without storing the full dataset. It merges the efficiency of online learning with the representational power of metric learning, making it suitable for streaming, large-scale, or continually changing environments where retraining from scratch is impractical.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Use Online Metric Learning when data arrive as a stream or in very large batches that preclude full batch re-training, when pairwise or triplet supervision is available sequentially (e.g., user feedback, click-through pairs), or when the similarity structure may drift over time. It is well-suited for retrieval, few-shot recognition, and ranking tasks. Avoid it when the full dataset is small and fits comfortably in memory — batch metric learning methods such as LMNN or NCA will typically converge to a better metric with less hyperparameter sensitivity. Also avoid when no pairwise or class-label supervision is available.
Strengths & limitations
- Processes one example at a time, requiring O(d²) memory for the metric matrix rather than O(n) for the full dataset.
- Adapts continuously to distribution shifts without full retraining, making it appropriate for non-stationary streams.
- Strong theoretical guarantees: online mistake bounds and regret bounds have been established for major algorithms.
- Generalises classical distance-based classifiers (k-NN) by learning a task-specific geometry.
- Compatible with pairwise labels, triplet constraints, or class-label supervision, offering flexible supervision signals.
- Learning a full d×d metric matrix scales quadratically with feature dimension; high-dimensional inputs (e.g., raw images) require low-rank or diagonal approximations.
- Convergence is sensitive to the learning rate and regularization schedule, which often need careful tuning per dataset.
- The PSD projection step adds computational overhead at each update.
- Less accurate than batch methods on small, stationary datasets where global optimization is feasible.
Frequently asked
How is Online Metric Learning different from batch metric learning (e.g., LMNN)?
Batch methods like LMNN optimize the metric over all training data simultaneously, achieving strong final accuracy but requiring full data access and expensive re-training when new data arrive. Online Metric Learning updates the metric after each example, trading some final-state accuracy for speed, memory efficiency, and adaptability to streaming or non-stationary data.
What supervision signal does Online Metric Learning need?
Most algorithms require pairwise constraints (similar / dissimilar labels for pairs) or triplet constraints (anchor, positive, negative). Some variants accept only class labels and derive implicit pairwise constraints on the fly. Pure unsupervised online metric learning is an active research area but less mature.
How do I handle high-dimensional input efficiently?
A full d×d PSD matrix becomes prohibitive for large d. Low-rank parameterizations (M = W^T W with W of rank k << d) or diagonal approximations (Euclidean weighting) reduce storage to O(kd) and make each update O(kd) rather than O(d²).
Can Online Metric Learning forget earlier constraints?
Yes — like all online algorithms it can exhibit catastrophic forgetting when the distribution shifts dramatically. Regularizing toward the previous metric (the Bregman divergence term in the update) slows but does not eliminate forgetting. For strong non-stationarity, reservoir sampling or memory replay of past constraints can mitigate this.
What evaluation metric should I use?
Common choices for retrieval tasks are Recall@k (fraction of true positives in the k nearest neighbors) and Mean Average Precision (MAP). For classification downstream, accuracy of a k-NN classifier under the learned metric is standard. Report results at multiple time steps across the stream to reveal adaptation dynamics.
Sources
- Shalev-Shwartz, S., Singer, Y., & Ng, A. Y. (2004). Online and batch learning of pseudo-metrics. Proceedings of the 21st International Conference on Machine Learning (ICML 2004), pp. 94. ACM. link ↗
- Jin, R., Wang, S., & Zhou, Y. (2009). Regularized distance metric learning: Theory and algorithm. Advances in Neural Information Processing Systems (NIPS 2009), 22, 862–870. link ↗
How to cite this page
ScholarGate. (2026, June 3). Online Metric Learning (Incremental Distance Metric Learning from Streaming Data). ScholarGate. https://scholargate.app/en/machine-learning/online-metric-learning
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- Metric LearningMachine learning↔ compare
- Online LearningMachine learning↔ compare
- Siamese NetworkDeep learning↔ compare