euclidean distance 和 cosine distance 欧几里得距离和余弦相似度

  1. 为什么探讨余弦相似度?
    During our ImageNet experiments, we found that euclidean distance led to poor performance when computing margins for the EVM. This is consistent with the previous finding that euclidean distance does not work well when comparing deep features of individual samples

参考文献:
C. C. Aggarwal, A. Hinneburg, and D. A. Keim, “On the surprising behavior of distance metrics in high dimensional space,” in Proc. Int. Conf. Database Theory, 2001, pp. 420–434.

  1. 余弦相似度公式:
    余弦相似度公式
  2. 先入为主地参考一下 Mr_EvanChen的博客,介绍的不错,还有python代码实现过程:
# consine相似度求解
import numpy as np
from scipy.spatial.distance import pdist
# 构造两个10维的数据:x,y
x=np.random.random(10)
y=np.random.random(10)
# solution1
dist1 = 1 - np.dot(x,y)/(np.linalg.norm(x)*np.linalg.norm(y))
# solution2
dist2 = pdist(np.vstack([x,y]),'cosine') 
print('x',x)
print('y',y)
print('dist1',dist1)
print('dist2',dist2)
  1. 图解余弦相似度,

图片来自参考文献:
刘建学, 李守军. 基于余弦相似度的因子分析在食品成分检测中的应用[J]. 食品科学, 2005, 26(6).

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wild kindom

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值