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 represented by the Greek letter ρ (rho) and may be referred to as the population correlation coefficient or the population Pearson correlation coefficient. The formula for ρ is:
where,
is the covariance,
is the standard deviation of
,
is the mean of
, and
is the expectation.
适合计算机运行的公式:
Alternative formulae for the sample Pearson correlation coefficient are also available:
The above formula suggests a convenient single-pass algorithm for calculating sample correlations, but, depending on the numbers involved, it can sometimes benumerically unstable.
Spearman's rank correlation coefficient
分析两个变量的一致性程度。
定义:
For a sample of size n, the n raw scores
are converted to ranks
, and ρ is computed from:

where
, is the difference between ranks
示例[编辑]
在此例中,我们要使用下表所给出的原始数据计算一个人的 智商和其每周花在 电视上的小时数的相关性。
智商, 
每周花在电视上的小时数, 
106
7
86
0
100
27
101
50
99
28
103
29
97
20
113
12
112
6
110
17
首先,我们必须根据以下步骤计算出
,如下表所示。
- 排列第一列数据 (
)。 创建新列
并赋以等级值 1,2,3,...n。
- 然后,排列第二列数据 (
). 创建第四列
并相似地赋以等级值 1,2,3,...n。
- 创建第五列
保存两个等级列的差值 (
和
).
- 创建最后一列
保存
的平方.
智商, 
每周花在电视上的小时数, 
等级 
等级 


86
0
1
1
0
0
97
20
2
6
−4
16
99
28
3
8
−5
25
100
27
4
7
−3
9
101
50
5
10
−5
25
103
29
6
9
−3
9
106
7
7
3
4
16
110
17
8
5
3
9
112
6
9
2
7
49
113
12
10
4
6
36
根据
计算
。 样本容量n为 10。 将这些值带入方程

得 ρ = −0.175757575...

For a sample of size n, the n raw scores
are converted to ranks
, and ρ is computed from:
where
, is the difference between ranks
示例[编辑]
在此例中,我们要使用下表所给出的原始数据计算一个人的 智商和其每周花在 电视上的小时数的相关性。
智商, ![]() |
每周花在电视上的小时数, ![]() |
| 106 | 7 |
| 86 | 0 |
| 100 | 27 |
| 101 | 50 |
| 99 | 28 |
| 103 | 29 |
| 97 | 20 |
| 113 | 12 |
| 112 | 6 |
| 110 | 17 |
首先,我们必须根据以下步骤计算出
,如下表所示。
- 排列第一列数据 (
)。 创建新列
并赋以等级值 1,2,3,...n。 - 然后,排列第二列数据 (
). 创建第四列
并相似地赋以等级值 1,2,3,...n。 - 创建第五列
保存两个等级列的差值 (
和
). - 创建最后一列
保存
的平方.
智商, ![]() |
每周花在电视上的小时数, ![]() |
等级 ![]() |
等级 ![]() |
![]() |
![]() |
| 86 | 0 | 1 | 1 | 0 | 0 |
| 97 | 20 | 2 | 6 | −4 | 16 |
| 99 | 28 | 3 | 8 | −5 | 25 |
| 100 | 27 | 4 | 7 | −3 | 9 |
| 101 | 50 | 5 | 10 | −5 | 25 |
| 103 | 29 | 6 | 9 | −3 | 9 |
| 106 | 7 | 7 | 3 | 4 | 16 |
| 110 | 17 | 8 | 5 | 3 | 9 |
| 112 | 6 | 9 | 2 | 7 | 49 |
| 113 | 12 | 10 | 4 | 6 | 36 |
根据
计算
。 样本容量n为 10。 将这些值带入方程
得 ρ = −0.175757575...

spark MLlib 概念 1:相关系数( PPMCC or PCC or Pearson's r皮尔森相关系数) and Spearman's correlation(史匹曼等级相关系数)的更多相关文章
- spark MLlib 概念 5: 余弦相似度(Cosine similarity)
概述: 余弦相似度 是对两个向量相似度的描述,表现为两个向量的夹角的余弦值.当方向相同时(调度为0),余弦值为1,标识强相关:当相互垂直时(在线性代数里,两个维度垂直意味着他们相互独立),余弦值为0, ...
- 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 ...
- spark MLlib 概念 4: 协同过滤(CF)
1. 定义 协同过滤(Collaborative Filtering)有狭义和广义两种意义: 广义协同过滤:对来源不同的数据,根据他们的共同点做过滤处理. Collaborative filterin ...
- spark MLlib 概念 3: 卡方分布(chi-squared distribution)
数学定义[编辑] 若k个随机变量.--.是相互独立,符合标准正态分布的随机变量(数学期望为0.方差为1),则随机变量Z的平方和 被称为服从自由度为 k 的卡方分布,记作 Definition[edit ...
- spark MLlib 概念 2:Stratified sampling 层次抽样
定义: In statistical surveys, when subpopulations within an overall population vary, it is advantageou ...
- Spark Mllib里的如何对单个数据集用斯皮尔曼计算相关系数
不多说,直接上干货! import org.apache.spark.mllib.stat.Statistics 具体,见 Spark Mllib机器学习实战的第4章 Mllib基本数据类型和Mlli ...
- Spark Mllib里的如何对两组数据用斯皮尔曼计算相关系数
不多说,直接上干货! import org.apache.spark.mllib.stat.Statistics 具体,见 Spark Mllib机器学习实战的第4章 Mllib基本数据类型和Mlli ...
- Spark Mllib里的如何对两组数据用皮尔逊计算相关系数
不多说,直接上干货! import org.apache.spark.mllib.stat.Statistics 具体,见 Spark Mllib机器学习实战的第4章 Mllib基本数据类型和Mlli ...
- Spark Mllib里的分布式矩阵(行矩阵、带有行索引的行矩阵、坐标矩阵和块矩阵概念、构成)(图文详解)
不多说,直接上干货! Distributed matrix : 分布式矩阵 一般能采用分布式矩阵,说明这数据存储下来,量还是有一定的.在Spark Mllib里,提供了四种分布式矩阵存储形式,均由支 ...
随机推荐
- Nginx配置,请求到tomcat中
一.web服务器分为两类 1.web服务器 1)Apache服务器 2)Nginx 3)IIS 2.web 应用服务器 1)tomcat 2)resin 3)jetty 区分:web服务器不能解析js ...
- LLVM 词典
#LLVM 词典 ## 本文转自https://github.com/oxnz/clang-user-manual/blob/master/LLVM-Language-Reference-Manual ...
- Linux中的grep 命令
介绍grep文本处理命令,它也可以解释正则. 常用选项: -E :开启扩展(Extend)的正则表达式. -i :忽略大小写(ignore case). -v :反过来(invert),只打印没有匹配 ...
- linux下/etc/rc.d目录的介绍及redhat启动顺序
init inittab rc0 rc1 rc2 rc3 rc5 rc6 rcS init.d init 系统启动超级进程 inittab 进程启动配置文件 rc0 - rc6 各启动级别的启动脚本 ...
- (持续更新中~~~)kafka--消息引擎与分布式流处理平台
kafka概述 kafka是一个分布式的基于发布/订阅模式的消息队列(message queue),一般更愿意称kafka是一款开源的消息引擎系统,只不过消息队列会耳熟一些.kafka主要应用于大数据 ...
- 一般情况下的NB-IoT网络架构
一. NB总体网络架构 NB-IoT端到端系统架构如下图所示: 终端:UE(User Equipment),通过空口连接到基站(eNodeB(evolved Node B , E-UTRAN 基站)) ...
- HTML5 App的代码注入攻击
原文链接 摘要 基于HTML5的手机app(译者注:以下简称HTML5 app)越来越流行了, 在大多数情况下它比native应用更容易适配不同的移动操作系统.它开发起来很方便,可以使用标准的web技 ...
- 微信小程序添加底部导航栏
修改 app.json 文件即可 "tabBar": { "selectedColor": "#1296db", "list&qu ...
- https://github.com/zabbix/zabbix-docker 安装
docker-compose -f ./docker-compose_v3_centos_mysql_latest.yaml up -d 解压文件,运行即可
- Observer-Proxy拦截器 -ES6
在目标对象前嫁接了一个拦截层,外界对该对象的访问都必须通过这层拦截 可实现观察者模式

