Cluster Analysis

PCA 适用于连续变量。目的是为了减少方差(squared deviations), 并可以将nominal改为binary,但是squared deviation不适用于二元变量(binary variables)
对于分类变量,MCA(multiple correspondence analysis) 更好
我们虽然可以对有序数据使用PCA (Likert scale), 但是相关性会很小
因此,对于分类问题我们使用 cluster analysis

Cluster Analysis

Statistical method of partitioning(分割) a sample into homogeneous classes

Purpose

  1. Sort observations into groups (or clusters) such that the degree of association is:
  • Strong between members of the same cluster
  • Weak between members of different clusters
  1. Define a formal classification scheme that was not previously evident

Supervised vs unsupervised learning

  1. Supervised
    Can train your model and use it for “new” data with some accuracy
    􏰀 Initial model: Use a portion of the data to “train” your data
    and ”test” using the remaining portion
    􏰀 e.g., Linear and logistic regression, negative binomial
  2. Unsupervised
    Does not use output data for further learning
    􏰀 e.g., Cluster analysis

Classification

  1. The classification produced is very dependent upon the particular method used. Therefore, it lacks an underlying body of statistical theory (heuristic in nature)
  2. It is possible to measure similarity and dissimilarity in a number of ways
  3. No such thing as a single correct classification
  4. Requires decisions by the user relating to classification that can have strong influence on results

Hierarchical or non-hierarchical

Hierarchical: Resultant classification has an increasing number of nested classes

Non-hierarchical: There is no hierarchy and the data are partitioned

  • Have a pre-determined number of cluster groups
  • k-means clustering

Divisive or agglomerative

Divisive (top down分割): begins with all cases in one cluster and is
gradually broken down into smaller clusters
Agglomerative (Bottom up聚合,较为常用): starts with single member
clusters and are gradually fused until one large cluster is formed

Classification Scheme: Monothetic or Polythetic

Monothetic: cluster membership is based on the presence or absence of a single characteristic (拥有点或缺失点) 就是根据有没有这个特征进行分类。
Polythetic: uses more than one characteristics (variable),较为常用

Polythetic, agglomerative classification steps

steps.png
  • Distance measures
    距离可以一维可以多维,可以是真实距离也可以是派生距离
  • Example Distance Measures
    -- Euclidean distance: most common(欧式距离):变量个体差值的平方和的平方根
    -- Squared Euclidean distance(平方欧式距离):变量个体差值的平方和
    -- City-black (Manhattan distance): cannot go in a diagonal
    -- Chebychev distance: defines two objects as different if they differ on ANY dimension变量差值的绝对值得最大值
    -- Power distance: accounts for progressive weight on individual dimensions
  • Clustering methods - example linkage
    In the agglomerative hierarchical clustering approach, distances are defined by a chosen distance measures
    -- Simple linkage: Nearest neighbor distance (if ANY object in one cluster is close to ANY object in another cluster)
    -- Complete linkage: measures distance between furthest objects
    -- Average linkage: based on distance from all objects in a group
    -- Centroid linkage: uses group centroids
    -- Ward’s method: uses sum of squares (variances)
    -- Density linkage
    -- Maximum likelihood...

我们需要多少的cluster?

自己定
也可以使用AIC = -2LL+2k or BIC = -2LL+log(n)k
并且使用dendrogram分析结果
R中适用silhouette plot 确定cluster的数量,最好不要使用scree plot

怎么算是成功的分类?

与别人的差异大,与自己人的差异小

  1. Each cluster is very different from other clusters (between
    cluster heterogeneity)
  2. Individuals within cluster are as similar as possible
    (within-cluster homogeneity)

Variance measures

  1. Root Mean Square Standard Deviation (RMSSTD)
    measures homogeneity within clusters 越小越好
  2. Semi-Partial R^2: measures loss of homogeneity due to merging (值越小两cluster越接近) 在merge时可以用到
  3. Centroid Distance: measures heterogeneity of clusters merged (值越大两cluster越不同)
  4. R2 (RS): extent to which clusters are different from each other; large if very different

有很多算法去优化cluster的数量

  1. Cubic Clustering Criterion (CCC) (Sarle, 1983): comparing the R2 for a cluster number with a default cluster
  2. Dynamic Local Search solves the number and location of the clusters jointly (Kärkkäinen and Fränti, ICPR 2002)

Hierarchical clustering

  1. Set up the distance matrix
    **分类变量采用非欧式距离
  2. Uses agglomerative approach(此时每一个observation均为一个cluster)
  3. 确定linkage method
  4. cut tree to three clusters
  5. check data
  6. plot groups

􏰀 Computing a dissimilarity matrix with categorical data
􏰀 Using Gower distance

Non-hierarchical

  • no hierarchical structure
  • pre-decide group numbers(与hierarchical聚类的区别)
  • three major approacher:
    (1) sequential threshold: 一次聚一类,即再聚下一类前遍历所有点
    (2) parallel threshold: 一次聚多类,实时更新点,mebership threshold distance 也会调整
    (3) optimizing:重新分配目标为了优化整体标准
  • setting a seed
    the number of partitions begins with a randomly chosen centroid

k-means clustering,一个典型的non-hierarchical聚类方法

sequential threshold
Step 1:选择初始k个聚类中心
Step 2: 考虑每个观测值并分配其到各个cluster
Step 3:cluster的中心在每次分配后重新计算

优势:1. 处理大量数据集时十分有效 2. often terminates at a local optimum 3. the clusters have convex shapes
劣势:1.针对数值型数据 2.需要提前决定聚类数量 3. 不能很好处理noisy data 和outliers 4. 不适用于non-convex的cluster

k均值聚类的结果差别会出现在
1.最初k值的选择;2. 相似性计算; 3.计算组均值的策略(hill-climbing)

为聚类类别性数据我们会使用k-mode,k-prototype同时适用于类别性数据和数值型数据

最后加一个分析
image.png

可以明显看出corona的分类主要是第二类。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,444评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,421评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,036评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,363评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,460评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,502评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,511评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,280评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,736评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,014评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,190评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,848评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,531评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,159评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,411评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,067评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,078评论 2 352

推荐阅读更多精彩内容