1

背景:我正在尝试 1)基于某些个体定义集群,以及 2)将其他个体分配给定义的集群。

已完成的工作:我使用FactoMineR函数PCA()HCPC()根据 Husson, F., Josse, J., Pages, J., 2010 描述的工作流程。主成分方法 - 层次聚类 - 分区聚类:我们为什么需要选择可视化数据?技术报告 – Agrocampus 17。

问题:可以分配每个补充个体(PCA(..., ind.sup =***)层次聚类分析中定义的集群?

类似的问题:这个问题已经在 stackoverflow 上被问过了,但那是 5 年前的事了,答案不适合 HCPC 工作流程。

请使用基本 R 数据集在下面的一些代码中找到mtcars

if(!require(FactoMineR)){install.packages("FactoMineR")}
library(FactoMineR)
if(!require(factoextra)){install.packages("factoextra")}
library(factoextra)

# lets use mtcars dataset for this question
head(mtcars)
# some individuals are considered as supplementary:
mtcars[22:nrow(mtcars),] 

# HCPC workflow
res.pca = PCA(mtcars, 
              ind.sup = c(22:nrow(mtcars)), # the last 10 individuals are supplementary
              scale.unit = TRUE, 
              ncp = 5, 
              graph = TRUE)
fviz_pca_ind(res.pca) # here supplementary individuals are included

res.hcpc = HCPC(res.pca, 
                nb.clust = -1, # automatic tree cut
                min = 3, 
                max = NULL, 
                graph = FALSE, 
                kk=Inf) # no k-means pre-processing
# here are the two results needed to illustrate my question
fviz_dend(res.hcpc, show_labels = TRUE)
res.hcpc$desc.ind # notice that individuals considered as supplementary are not included in any cluster

预期输出:预期输出是这样的,其中补充个体被分配到集群并明确标识:[预期图形输出示例](https://i.stack.imgur.com/ZrOwu.png). 例如,将菲亚特 X-9 和 Lotus Europa(补充人员)分配到集群中,菲亚特 128。

4

0 回答 0