参考:http://scikit-learn.org/stable/modules/metrics.html
The sklearn.metrics.pairwise submodule implements utilities to evaluate pairwise distances(样本对的距离) or affinity of sets of samples(样本集的相似度)。
Distance metrics are functions d(a, b) such that d(a, b) < d(a, c) if objects a and b are considered “more similar” than objects a and c.
Kernels are measures of similarity, i.e. s(a, b) > s(a, c) if objects a and b are considered “more similar” than objects a and c.
1、Cosine similarity
向量点积的L2-norm:
if and
are row vectors, their cosine similarity