Euclidean, Cosine and Angular Similarity and Distance

버전 1.1.0 (5.22 KB) 작성자: Hristo Zhivomirov
Calculation of the Euclidean, cosine and angular similarity and distance between two sets of data.
다운로드 수: 122
업데이트 날짜: 2021/10/10

라이선스 보기

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!
버전 게시됨 릴리스 정보
1.1.0

A new version of the codes has been uploaded.

1.0.0