概述:
余弦相似度 是对两个向量相似度的描述,表现为两个向量的夹角的余弦值。当方向相同时(调度为0),余弦值为1,标识强相关;当相互垂直时(在线性代数里,两个维度垂直意味着他们相互独立),余弦值为0,标识他们无关。
Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cosine of 0° is 1, and it is less than 1 for any other angle. It is thus a judgement of orientation and not magnitude: two vectors with the same orientation have a Cosine similarity of 1, two vectors at 90° have a similarity of 0, and two vectors diametrically opposed have a similarity of -1, independent of their magnitude. Cosine similarity is particularly used in positive space, where the outcome is neatly bounded in [0,1].

定义
基础知识。。

The cosine of two vectors can be derived by using the Euclidean dot product formula:

Given two vectors of attributes, A and B, the cosine similarity, cos(θ), is represented using a dot product and magnitude as

The resulting similarity ranges from −1 meaning exactly opposite, to 1 meaning exactly the same, with 0 usually indicating independence, and in-between values indicating intermediate similarity or dissimilarity.

与皮尔森相关系数的关系
If the attribute vectors are normalized by subtracting the vector means (e.g., ), the measure is called centered cosine similarity and is equivalent to the Pearson Correlation Coefficient.









spark MLlib 概念 5: 余弦相似度(Cosine similarity)的更多相关文章

  1. 相似度度量:欧氏距离与余弦相似度(Similarity Measurement Euclidean Distance Cosine Similarity)

    在<机器学习---文本特征提取之词袋模型(Machine Learning Text Feature Extraction Bag of Words)>一文中,我们通过计算文本特征向量之间 ...

  2. 余弦相似度-Cosine Similar(转载)

    余弦相似度用向量空间中两个向量夹角的余弦值作为衡量两个个体间差异的大小.相比距离度量,余弦相似度更加注重两个向量在方向上的差异,而非距离或长度上. 与欧几里德距离类似,基于余弦相似度的计算方法也是把用 ...

  3. spark MLlib 概念 4: 协同过滤(CF)

    1. 定义 协同过滤(Collaborative Filtering)有狭义和广义两种意义: 广义协同过滤:对来源不同的数据,根据他们的共同点做过滤处理. Collaborative filterin ...

  4. spark MLlib 概念 6:ALS(Alternating Least Squares) or (ALS-WR)

    Large-scale Parallel Collaborative Filtering for the Netflix Prize http://www.hpl.hp.com/personal/Ro ...

  5. spark MLlib 概念 3: 卡方分布(chi-squared distribution)

    数学定义[编辑] 若k个随机变量.--.是相互独立,符合标准正态分布的随机变量(数学期望为0.方差为1),则随机变量Z的平方和 被称为服从自由度为 k 的卡方分布,记作 Definition[edit ...

  6. spark MLlib 概念 2:Stratified sampling 层次抽样

    定义: In statistical surveys, when subpopulations within an overall population vary, it is advantageou ...

  7. spark MLlib 概念 1:相关系数( PPMCC or PCC or Pearson's r皮尔森相关系数) and Spearman's correlation(史匹曼等级相关系数)

    皮尔森相关系数定义: 协方差与标准差乘积的商. Pearson's correlation coefficient when applied to a population is commonly r ...

  8. Spark MLlib

    MLlib    数据挖掘与机器学习        数据挖掘体系 数据挖掘:也就是data mining,是一个很宽泛的概念,也是一个新兴学科,旨在如何从海量数据中挖掘出有用的信息来.         ...

  9. Sequence Model-week2编程题1-词向量的操作【余弦相似度 词类比 除偏词向量】

    1. 词向量上的操作(Operations on word vectors) 因为词嵌入的训练是非常耗资源的,所以ML从业者通常 都是 选择加载训练好 的 词嵌入(Embedding)数据集.(不用自 ...

随机推荐

  1. LLVM源码安装教程

    LLVM4.0源码安装教程 环境:ubuntu16.04 llvm-4.0 clang-4.0 步骤: 1.依赖库安装,注意llvm的编译对gcc版本和cmake版本有要求,请根据版本进行匹配 $ s ...

  2. ActiveMQ基础01——Linux下载安装ActiveMQ

    1.下载 下载地址:http://activemq.apache.org/ 点击按钮 下载Linux下最新版安装包,点击即可下载 2.安装ActiveMQ 将之前下载的安装包上传到linux当中,一般 ...

  3. python-迭代器与生成器2

    python-迭代器与生成器2 def fib(max): n,a,b=0,0,1 while n<max: #print(b) yield b a,b=b,a+b #t=(b,a+b) 是一个 ...

  4. Mac下的LDAP客户端 ApacheDirectoryStudio

    mac下的ldap browser,最开始下载的最新版本的 地址 http://directory.apache.org/studio/downloads.html 使用的时候经常卡死,尝试下载老版本 ...

  5. Vue基础组件

    本文章仅用作于个人学习笔记(蓝后我就可以乱写啦)复制代码 一.组件化的优点当TodoList的todo item越来越多的时候,我们应该把它拆分成一个组件进行开发,维护.组件的出现,就是为了拆分Vue ...

  6. xhost + command not found

    如下是一个示例: 原本我以为在没有联网的情况下.不能使用yum 的.可能是本地配置了yum 了吧也可以使用 1. [oracle@11GR2-test ~]$ export DISPLAY=192.1 ...

  7. A RECURRENT NEURAL NETWORK WITHOUT CHAOS

    本篇文章的介绍了一个非常简单的门限RNN(gated recurrent neural network), 这里有两扇门horizontal/forget gate和vertical/input ga ...

  8. POJ2449 K短路模板

    #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> ...

  9. 使用 mybatis-Generator 自动生成DAO、Model、Mapping相关文件

    1.Maven项目 2.配置generatorConfig.xml文件 3.在pom.xml中配置插件 2.generatorConfig.xml文件信息 <?xml version=" ...

  10. Java的面向对象属性

    定义类 定义类的过程就是定义类的属性的过程: 类的属性就是累的静态属性的简称,指类内包含的各项数据. 类的服务被称为成员函数或方法. 继承extends 通过定义继承方法,子类可以获得父类的所有属性和 ...