聚类分析
Chap 6 : 聚类分析
主要内容
6.1 概述 6.2 相似度衡量方法 6.3 k均值方法 6.4 层次聚类方法
6.5 DBSCAN方法
6.6 聚类效果衡量方法
2
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
13
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
基于距离的相似度
1 s(oi , o j ) 1 d (oi , o j )
s(oi , o j ) d (oi , o j )
s(oi , o j ) e
基本概念
根据簇之间的关系
划分型聚类:属于各个簇的对象之间没有交集,即 Ci∩Cj= 层次型聚类:簇之间只具有包含关系,如CiCj 重叠聚类: 簇之间只具有重叠关系,即Ci∩Cj≠
根据数据集D与簇之间的关系
完全聚类: D= C1∪C2∪…∪Ck,所有对象都被分配都簇中
部分聚类: DC1∪C2∪…∪Ck
9
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
数据类型
定量属性
标称(nominal)属性、序数(ordinal)属性、二值属性 (binary) 二值属性:对称属性(symmetric)和非对称属性 (asymmeric)
d(o , o ) (| x x |2 | x x |2 ... | x x |2 ) i j i1 j 1 i2 j 2 im jm 性质:
d(oi,oj) 0
d(oi, oi) = 0
d(oi,oj) = d(oj,oi) d(oi,oj) doi,ok) + d(ok,oj)
1 m xi xik m k 1
corr(oi, oj)的取值范围为[-1,1]。取值为1时说明两 个对象正相关,也最相似,取值为-1时说明两个对 象负相关,也最不相似
16
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
cos (oi , o j )
x
k 1 2
ik
x jk
k 1 xik
m
2 x k 1 jk m
x y || x || || y ||
相似度忽略了向量的大小,即各个属性取值的绝对大小, 这是与距离不同的。
两个向量中,只要有一个对象在某维度(属性)的取值 为0,则该维度相当于被忽略,因为乘积为0。这使得该 相似度特别适合于具有大量零值维度的情况
孤立点(outlier):那些未被分到任一个簇中的对象
6
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
聚类方法分类
划分法(Partitioning approach):
k均值(k-means)、k中心点(k-medoids)等方法。
n11 n00 s(oi , o j ) n11 n10 n01 n00
18
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
二值属性
列联表
1
Object i Object j
0 b d
sum a b cd p
19
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
Jaccard系数
Y , P: 1; N : 0
Name Jack Mary Jim Fever Y Y Y Cough N N P
s(i, j)
Test-1 P P N
15
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
基于相关性的相似度度量
对象oi=(xi1, xi2,…, xim)和oj=(xj1, xj2,…, xjm)的皮尔森相 关系数corr(oi, oj)的计算公式如下
d ( oi ,o j )
14
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
余弦相似度
假设两个对象oi和oj对应的向量分别为x= (xi1, xi2,…, xim)和y=(xj1, xj2,…, xjm),则余弦相似度cos(oi, oj)的计 算公式 m
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
Introduction to
商务智能方法与应用
第6章 聚类分析
Chapter6: Clustering
1
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
基于内容的相似度衡量
基于距离的相似度度量 余弦相似度 基于相关性的相似度度量 Jaccard系数
异种属性相似度的综合度量
11
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
6.1 概述
聚类(clustering):
实现将对象自动分组的一 种方法
编 号 100 200 300 400 500 账户 余额 很低 高 中 低 低 年龄 收入 性别
无监督学习
15 25 32 20 55
1967 8453 6125 2167 2439
男 男 女 男 女
子女 个数 0 1 2 1 4
1 0
a c
sum a c b d
Simple matching coefficient (对称属性): s(i, j)
ad abcd
c Jaccard distance (非对称属性) d (i, j) a b bc Jaccard coefficient s(i, j) a a bc
corr (oi , o j ) 1 m ( xik xi ) ( x jk x j ) m 1 k 1 m m 1 1 2 2 ( x x ) ( x x ) ik i m 1 k 1 jk j m 1 k 1
1 m x j x jk m k 1
Jaccard系数
适合于用非对称二值属性描述的对象间的相似度衡 量。
对于非对称二值属性,假设重要的取值用1代表,不重要 的用0代表,对象oi=(xi1, xi2,…, xim)和oj=(xj1, xj2,…, xjm)的m 个二值属性取值中,假设两个对象取值都为1的属性个数 为n11,取值都为0的属性个数为n00,取值一个为1另一个 为0的属性个数为n10,取值一个为0另一个为1的属性个数 为n01
n11 s(oi , o j ) n11 n10 n01
17
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
简单匹配系数(simple matching coefficient)
对于用对称二值属性描述的对象间的相似度可以利 用简单匹配系数进行衡量。
Chap 6 : 聚类分析
6.2 相似度衡量方法
8
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
6.2 相似度衡量方法
6.2.1 数据类型 6.2.2 基于内容的相似度衡量 6.2.3 基于链接的相似度衡量
生物: 动植物分类(taxonomy)
4
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
基本概念
5
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
距离度量
明可夫斯基距离Minkowski distance:
i = (xi1, xi2, …, xim) 和j = (xj1, xj2, …, xjm)
明可夫斯基距离又称为Lp范式(Lp范式) ,p=1时对应曼哈顿 距离,又称L1范式;p=2时对应欧式距离,又称L2范式。 p=时称为切比雪夫距离(Chebyshev distance)
物以类聚
3
Principles and Applications of Business Intelligence
Chap 6 : 聚类分析
应用
CRM中的客户分群: customer segmentation Insurance保险: Identifying groups of motor insurance policy holders with a high average claim cost 高索赔额 的汽车保险的投保人 City-planning: Identifying groups of houses according to their house type, value, and geographical location WWW: 根据 Weblog 数据发现相似的访问模式