Similarity learning
Similarity learning is an area of supervised machine learning in artificial intelligence. It is closely related to regression and classification, but the goal is to learn a similarity function that measures how similar or related two objects are. It has applications in ranking, in recommendation systems, visual identity tracking, face verification, and speaker verification.
Learning setup
There are four common setups for similarity and metric distance learning.
- Regression similarity learning
- In this setup, pairs of objects are given [math]\displaystyle{ (x_i^1, x_i^2) }[/math] together with a measure of their similarity [math]\displaystyle{ y_i \in R }[/math]. The goal is to learn a function that approximates [math]\displaystyle{ f(x_i^1, x_i^2) \sim y_i }[/math] for every new labeled triplet example [math]\displaystyle{ (x_i^1, x_i^2, y_i) }[/math]. This is typically achieved by minimizing a regularized loss [math]\displaystyle{ \min_W \sum_i loss(w;x_i^1, x_i^2,y_i) + reg(w) }[/math].
- Classification similarity learning
- Given are pairs of similar objects [math]\displaystyle{ (x_i, x_i^+) }[/math] and non similar objects [math]\displaystyle{ (x_i, x_i^-) }[/math]. An equivalent formulation is that every pair [math]\displaystyle{ (x_i^1, x_i^2) }[/math] is given together with a binary label [math]\displaystyle{ y_i \in \{0,1\} }[/math] that determines if the two objects are similar or not. The goal is again to learn a classifier that can decide if a new pair of objects is similar or not.
- Ranking similarity learning
- Given are triplets of objects [math]\displaystyle{ (x_i, x_i^+, x_i^-) }[/math] whose relative similarity obey a predefined order: [math]\displaystyle{ x_i }[/math] is known to be more similar to [math]\displaystyle{ x_i^+ }[/math] than to [math]\displaystyle{ x_i^- }[/math]. The goal is to learn a function [math]\displaystyle{ f }[/math] such that for any new triplet of objects [math]\displaystyle{ (x, x^+, x^-) }[/math], it obeys [math]\displaystyle{ f(x, x^+) \gt f(x, x^-) }[/math] (contrastive learning). This setup assumes a weaker form of supervision than in regression, because instead of providing an exact measure of similarity, one only has to provide the relative order of similarity. For this reason, ranking-based similarity learning is easier to apply in real large-scale applications.[1]
- Locality sensitive hashing (LSH)[2]
- Hashes input items so that similar items map to the same "buckets" in memory with high probability (the number of buckets being much smaller than the universe of possible input items). It is often applied in nearest neighbor search on large-scale high-dimensional data, e.g., image databases, document collections, time-series databases, and genome databases.[3]
A common approach for learning similarity is to model the similarity function as a bilinear form. For example, in the case of ranking similarity learning, one aims to learn a matrix W that parametrizes the similarity function [math]\displaystyle{ f_W(x, z) = x^T W z }[/math]. When data is abundant, a common approach is to learn a siamese network – a deep network model with parameter sharing.
Metric learning
Similarity learning is closely related to distance metric learning. Metric learning is the task of learning a distance function over objects. A metric or distance function has to obey four axioms: non-negativity, identity of indiscernibles, symmetry and subadditivity (or the triangle inequality). In practice, metric learning algorithms ignore the condition of identity of indiscernibles and learn a pseudo-metric.
When the objects [math]\displaystyle{ x_i }[/math] are vectors in [math]\displaystyle{ R^d }[/math], then any matrix [math]\displaystyle{ W }[/math] in the symmetric positive semi-definite cone [math]\displaystyle{ S_+^d }[/math] defines a distance pseudo-metric of the space of x through the form [math]\displaystyle{ D_W(x_1, x_2)^2 = (x_1-x_2)^{\top} W (x_1-x_2) }[/math]. When [math]\displaystyle{ W }[/math] is a symmetric positive definite matrix, [math]\displaystyle{ D_W }[/math] is a metric. Moreover, as any symmetric positive semi-definite matrix [math]\displaystyle{ W \in S_+^d }[/math] can be decomposed as [math]\displaystyle{ W = L^{\top}L }[/math] where [math]\displaystyle{ L \in R^{e \times d} }[/math] and [math]\displaystyle{ e \geq rank(W) }[/math], the distance function [math]\displaystyle{ D_W }[/math] can be rewritten equivalently [math]\displaystyle{ D_W(x_1, x_2)^2 = (x_1-x_2)^{\top} L^{\top}L (x_1-x_2) = \| L (x_1-x_2) \|_2^2 }[/math]. The distance [math]\displaystyle{ D_W(x_1, x_2)^2=\| x_1' - x_2' \|_2^2 }[/math] corresponds to the Euclidean distance between the transformed feature vectors [math]\displaystyle{ x_1'= Lx_1 }[/math] and [math]\displaystyle{ x_2'= Lx_2 }[/math].
Many formulations for metric learning have been proposed.[4][5] Some well-known approaches for metric learning include learning from relative comparisons,[6] which is based on the triplet loss, large margin nearest neighbor,[7] and information theoretic metric learning (ITML).[8]
In statistics, the covariance matrix of the data is sometimes used to define a distance metric called Mahalanobis distance.
Applications
Similarity learning is used in information retrieval for learning to rank, in face verification or face identification,[9][10] and in recommendation systems. Also, many machine learning approaches rely on some metric. This includes unsupervised learning such as clustering, which groups together close or similar objects. It also includes supervised approaches like K-nearest neighbor algorithm which rely on labels of nearby objects to decide on the label of a new object. Metric learning has been proposed as a preprocessing step for many of these approaches.[11]
Scalability
Metric and similarity learning naively scale quadratically with the dimension of the input space, as can easily see when the learned metric has a bilinear form [math]\displaystyle{ f_W(x, z) = x^T W z }[/math]. Scaling to higher dimensions can be achieved by enforcing a sparseness structure over the matrix model, as done with HDSL,[12] and with COMET.[13]
Software
- metric-learn[14] is a free software Python library which offers efficient implementations of several supervised and weakly-supervised similarity and metric learning algorithms. The API of metric-learn is compatible with scikit-learn.[15]
- OpenMetricLearning[16] is a Python framework to train and validate the models producing high-quality embeddings.
Further information
For further information on this topic, see the surveys on metric and similarity learning by Bellet et al.[4] and Kulis.[5]
See also
References
- ↑ Chechik, G.; Sharma, V.; Shalit, U.; Bengio, S. (2010). "Large Scale Online Learning of Image Similarity Through Ranking". Journal of Machine Learning Research 11: 1109–1135. http://www.jmlr.org/papers/volume11/chechik10a/chechik10a.pdf.
- ↑ Gionis, Aristides, Piotr Indyk, and Rajeev Motwani. "Similarity search in high dimensions via hashing." VLDB. Vol. 99. No. 6. 1999.
- ↑ "Mining of Massive Datasets, Ch. 3.". 2010. http://infolab.stanford.edu/~ullman/mmds.html.
- ↑ 4.0 4.1 Bellet, A.; Habrard, A.; Sebban, M. (2013). "A Survey on Metric Learning for Feature Vectors and Structured Data". arXiv:1306.6709 [cs.LG].
- ↑ 5.0 5.1 Kulis, B. (2012). "Metric Learning: A Survey". Foundations and Trends in Machine Learning 5 (4): 287–364. doi:10.1561/2200000019. https://www.nowpublishers.com/article/Details/MAL-019.
- ↑ Schultz, M.; Joachims, T. (2004). "Learning a distance metric from relative comparisons". Advances in Neural Information Processing Systems 16: 41–48. https://papers.nips.cc/paper/2366-learning-a-distance-metric-from-relative-comparisons.pdf.
- ↑ Weinberger, K. Q.; Blitzer, J. C.; Saul, L. K. (2006). "Distance Metric Learning for Large Margin Nearest Neighbor Classification". Advances in Neural Information Processing Systems 18: 1473–1480. http://books.nips.cc/papers/files/nips18/NIPS2005_0265.pdf.
- ↑ Davis, J. V.; Kulis, B.; Jain, P.; Sra, S.; Dhillon, I. S. (2007). "Information-theoretic metric learning". International Conference in Machine Learning (ICML): 209–216. http://www.cs.utexas.edu/users/pjain/itml/.
- ↑ Guillaumin, M.; Verbeek, J.; Schmid, C. (2009). "Is that you? Metric learning approaches for face identification". IEEE International Conference on Computer Vision (ICCV). http://hal.inria.fr/docs/00/58/50/36/PDF/verbeek09iccv2.pdf.
- ↑ Mignon, A.; Jurie, F. (2012). "PCCA: A new approach for distance learning from sparse pairwise constraints". IEEE Conference on Computer Vision and Pattern Recognition. http://hal.archives-ouvertes.fr/docs/00/80/60/07/PDF/12_cvpr_ldca.pdf.
- ↑ Xing, E. P.; Ng, A. Y.; Jordan, M. I.; Russell, S. (2002). "Distance Metric Learning, with Application to Clustering with Side-information". Advances in Neural Information Processing Systems 15: 505–512. https://ai.stanford.edu/~ang/papers/nips02-metric.pdf.
- ↑ Liu; Bellet; Sha (2015). "Similarity Learning for High-Dimensional Sparse Data". International Conference on Artificial Intelligence and Statistics (AISTATS). Bibcode: 2014arXiv1411.2374L. http://jmlr.org/proceedings/papers/v38/liu15.pdf.
- ↑ Atzmon; Shalit; Chechik (2015). "Learning Sparse Metrics, One Feature at a Time". J. Mach. Learn. Research (JMLR). http://jmlr.org/proceedings/papers/v44/atzmon2015.pdf.
- ↑ https://github.com/scikit-learn-contrib/metric-learn
- ↑ Vazelhes; Carey; Tang; Vauquier; Bellet (2020). "metric-learn: Metric Learning Algorithms in Python". J. Mach. Learn. Research (JMLR). https://www.jmlr.org/papers/volume21/19-678/19-678.pdf.
- ↑ https://github.com/OML-Team/open-metric-learning
![]() | Original source: https://en.wikipedia.org/wiki/Similarity learning.
Read more |