s1=(x1,x2,x3)s_1=(x_1,x_2,x_3)s1=(x1,x2,x3)
s2=(y1,y2,y3)s_2=(y_1,y_2,y_3)s2=(y1,y2,y3)
欧氏距离
d=∣s1−s2∣=(x12−y12)+(x22−y22)+(x32−y32) d=|s_1-s_2|=\sqrt{(x_1^2-y_1^2)+(x_2^2-y_2^2)+(x_3^2-y_3^2)} d=∣s1−s2∣=(x12−y12)+(x22−y22)+(x32−y32)
特点:只考虑距离,没考虑方向,距离越小说明越相似
余弦相似度
tf=s1⋅s2(∣s1∣×∣s2∣)=(x1×y1)+(x2×y2)+(x3×y3)(x12+x22+x32)(y12+y22+y32) tf=\frac{s_1·s_2} {(|s_1|\times|s_2|)} =\frac{(x_1\times y_1)+(x_2\times y_2)+(x_3\times y_3)} { \sqrt{(x_1^2+x_2^2+x_3^2)}\sqrt{(y_1^2+y_2^2+y_3^2)}} tf=(∣s1∣×∣s