The present code is a set of three Matlab functions that provide calculation of six metrics:
- Euclidean distance, which vary in the range of [0 : Inf]. Larger values indicate high distance;
- Euclidean similarity, which vary in the range of [0 : 1]. Larger values indicate high similarity;
- cosine distance, which vary in the range of [0 : 2]. Larger values indicate high distance;
- cosine similarity, which vary in the range of [-1 : 1]. Larger values indicate high similarity;
- angular distance, which vary in the range of [0 : 1]. Larger values indicate high distance;
- angular similarity, which vary in the range of [0 : 1]. Larger values indicate high similarity.
The similarity and distance metrics are bound together – the smaller the distance is, the larger the similarity will get, and vice versa.
A few examples are given in order to clarify the usage of the functions. For convenience, the input and output arguments are given in the beginning of each function.
The code is based on the theory described in:
[1] T. Segaran. Programming Collective Intelligence, Ch. 2. Sebastopol, O’Reilly Media, 2007.
[2] E. Vezzetti, F. Marcolin. Similarity Measures for Face Recognition, Ch 5. Sharjah, Bentham Science Publishers, 2015.
[3] D. Cer, Y. Yang, S. Kong, N. Hua, N. Limtiaco, R. John, N. Constant, M. Guajardo-Céspedes, S. Yuan, C. Tar, Y. Sung, B. Strope and R. Kurzweil. Universal sentence encoder for English. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 169-174, 2018.
인용 양식
Hristo Zhivomirov (2024). Euclidean, Cosine and Angular Similarity and Distance (https://www.mathworks.com/matlabcentral/fileexchange/98474-euclidean-cosine-and-angular-similarity-and-distance), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2017b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!