最近,我尝试在多元矩阵( 196 var的400 obs )上执行R中的GMM,该矩阵的元素属于已知类别。Mclust()函数(来自软件包mclust)给出的结果很差(约30%的个体被很好地分类,而k-表示结果超过90%)。
这是我的代码:
library(mclust)
X <- read.csv("X.csv", sep = ",", h = T)
y <- read.csv("y.csv", sep = ",")
gmm <- Mclust(X, G = 5) #I want 5 clusters
cl_gmm <- gmm$classification
cl_gmm_lab <- cl_gmm
for (k in 1:nclusters){
ii = which(cl_gmm == k) # individuals of group k
counts=table(y[ii]) # number of occurences for each label
imax = which.max(counts) # Majority label
maj_lab = attributes(counts)$dimnames[[1]][imax]
print(paste("Group ",k,", majority label = ",maj_lab))
cl_gmm_lab[ii] = maj_lab
}
conf_mat_gmm <- table(y,cl_gmm_lab) # CONFUSION MATRIX这个问题似乎来自于这样一个事实:当查看gmm$BIC时,"EII“(球形,等容量)以外的每一种模型都是"NA”。
直到现在我还没有找到解决这个problem...are的办法,你熟悉这个问题吗?
下面是数据的链接:https://drive.google.com/file/d/1j6lpqwQhUyv2qTpm7KbiMRO-0lXC3aKt/view?usp=sharing,这里是标签的链接:https://docs.google.com/spreadsheets/d/1AVGgjS6h7v6diLFx4CxzxsvsiEm3EHG7/edit?usp=sharing&ouid=103045667565084056710&rtpof=true&sd=true
发布于 2022-10-19 06:55:03
我终于找到了答案。当涉及两个解释性变量时,GMM根本无法应用每个模型。正确的做法是首先减少维数,并选择一个最佳维数,以便在保存尽可能多的数据信息的同时,能够正确地应用GMMs。
https://stackoverflow.com/questions/73906228
复制相似问题