Euclidean, Cosine and Angular Similarity and Distance

版本 1.1.0 (5.2 KB) 作者: Hristo Zhivomirov
Calculation of the Euclidean, cosine and angular similarity and distance between two sets of data.
126.0 次下载
更新时间 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