当前位置:网站首页>余弦距离介绍
余弦距离介绍
2022-08-03 19:08:00 【xiaozheng123121】
目录
作者:CSDN博主「深度学习视觉」
原文链接:https://blog.csdn.net/lucky_kai/article/details/89514868
————————————————
概述: 在机器学习领域中,通常将特征表示为向量的形式,所以在分析两个特征向量之间的相似性时,常用余弦相似度表示。
例如将两篇文章向量化,余弦距离可以避免因为文章的长度不同而导致距离偏大,余弦距离只考虑两篇文章生成的向量的夹角。
余弦相似度的取值范围是[-1,1],相同两个向量的之间的相似度为1。
余弦距离的取值范围是[0,2]。
余弦相似度的定义公式为 c o s ( A , B ) = A ⋅ B ∥ A ∥ 2 ∥ B ∥ 2 cos(A,B)=\frac{A\cdot B}{\left\|A \right\|_2\left\|B \right\|_2} cos(A,B)=∥A∥2∥B∥2A⋅B
归一化后: ∥ A ∥ 2 = 1 , ∥ B ∥ 2 = 1 , ∥ A ∥ 2 ∥ B ∥ 2 = 1 \left\|A\right\|_2=1, \left\|B\right\|_2=1, \left\|A\right\|_2\left\|B\right\|_2=1 ∥A∥2=1,∥B∥2=1,∥A∥2∥B∥2=1
余弦距离: d i s t ( A , B ) = 1 − c o s ( A , B ) = ∥ A ∥ 2 ∥ B ∥ 2 − A ⋅ B ∥ A ∥ 2 ∥ B ∥ 2 dist(A,B)=1-cos(A,B)=\frac{\left\|A \right\|_2\left\|B \right\|_2-A\cdot B}{\left\|A \right\|_2\left\|B \right\|_2} dist(A,B)=1−cos(A,B)=∥A∥2∥B∥2∥A∥2∥B∥2−A⋅B,距离恒大于0
欧式距离:
由公式可以看出归一化后,欧式距离与余弦距离存在单调性关系。此时两种距离的值域都为[0,2]。
欧式距离与余弦距离的对比:
1.欧式距离的数值受到维度的影响,余弦相似度在高维的情况下也依然保持低维完全相同时相似度为1等性质。
2.欧式距离体现的是距离上的绝对差异,余弦距离体现的是方向上的相对差异。
边栏推荐
- Postgresql snapshot optimization Globalvis new system analysis (performance greatly enhanced)
- Brush the topic of mobile zero power button
- Big guy, who is free to help me to see what the problem is, I just read MySQL source print, and I just came into contact with flink.
- [Azure Event Hub] Create Event Hub Consume Client + Custom Event Position with Azure AD Authentication
- 力扣刷题之合并两个有序数组
- [笔记]机器学习之前言介绍
- Handler 源码解析
- Compose原理-compose中是如何实现事件分法的
- ctfshow php特性
- Alibaba senior experts create a learning architecture from scratch, including Alibaba's internal technology stack PPT, PFD actual combat
猜你喜欢
JumpServer开源堡垒机完成龙芯架构兼容性认证
Confused!Ali was abused on the one hand, but was fortunate to be promoted to Huawei's technology, and successfully got the offer, with an annual salary of 40w
阿里巴巴政委体系-第八章、阿里政委工作方法论
面试突击:什么是粘包和半包?怎么解决?
梅科尔工作室-14天华为培训七
要想成为黑客,离不开这十大基础知识
idea——同一项目开启多个实例(不同端口)
Protobuf Grpc使用异常 类型有未导出的方法,并且是在不同的软件包中定义
MySQL【变量、流程控制与游标】
实时渲染器不止lumion,Chaos Vantage你值得一试
随机推荐
京东云发布新一代分布式数据库StarDB 5.0
面试突击:什么是粘包和半包?怎么解决?
安装radondb mysql遇到问题
阿里巴巴政委体系-第八章、阿里政委工作方法论
MySQL如何一劳永逸的永久支持输入中文
Postgresql源码(65)新快照体系Globalvis工作原理分析
【C语言学习笔记(五)】while循环与for循环
C#爬虫之通过Selenium获取浏览器请求响应结果
Web项目中简单使用线程池
MySQL如何 drop 大表
使用安全浏览器将网页保存为pdf的方法步骤
pg_memory_barrier_impl in Postgresql and C's volatile
Confused!Ali was abused on the one hand, but was fortunate to be promoted to Huawei's technology, and successfully got the offer, with an annual salary of 40w
要想成为黑客,离不开这十大基础知识
Solution for no navigation bar after Word is saved as PDF
G6尝试 学习
力扣刷题之移动零
X86函数调用模型分析
基于DMS的数仓智能运维服务,知多少?
关于2022年度深圳市技术攻关重大项目的申报通知