如何确定使用 R 进行 kamila 聚类的最佳聚类数?
How to decide best number of clusters for kamila clustering with R?
我有一个混合类型的数据集,所以我想尝试 kamila
聚类。它很容易应用,但我想要一个类似于膝盖图的图来决定簇的数量。
data <- read.csv("binarymat.csv",header=FALSE,sep=";")
conInd <- c(9)
conVars <- data[,conInd]
conVars <- data.frame(scale(conVars))
catVarsFac <- data[,c(1,2,3,4,5,6,7,8)]
catVarsFac[] <- lapply(catVarsFac, factor)
catVarsDum <- dummyCodeFactorDf(catVarsFac)
kamRes <- kamila(conVars, catVarsFac, numClust=5, numInit=10,
calcNumClust = "ps",numPredStrCvRun = 10, predStrThresh = 0.5)
summary(kamRes)
它说最好的簇数是 5。它是如何决定的,我可以看到指示这一点的图吗?
在 kamila
包文档中
Setting calcNumClust to ’ps’ uses the prediction strength method of
Tibshirani & Walther (J. of Comp. and Graphical Stats. 14(3), 2005).
There is no perfect method for estimating the number of clusters; PS
tends to give a smaller number than, say, BIC based methods for large
sample sizes.
在您使用它的情况下,您只为 numClust
指定了 一个 值。因此,看起来您实际上并没有 select 计算集群的数量 - 您已经选择了一个。
到select簇数,你要指定你感兴趣的范围,比如numClust = 2 : 7
还有select簇数的方法.
如果您还想 select 集群的数量,类似下面的方法可能会起作用。
kamRes <- kamila(conVars, catVarsFac, numClust = 2 : 7, numInit = 10,
calcNumClust = "ps", numPredStrCvRun = 10, predStrThresh = 0.5)
关于select簇数量的信息现在存在于
kamRes$nClust
,plot(2:7, kamRes$nClust$psValues)
可能就是您想要的。
我有一个混合类型的数据集,所以我想尝试 kamila
聚类。它很容易应用,但我想要一个类似于膝盖图的图来决定簇的数量。
data <- read.csv("binarymat.csv",header=FALSE,sep=";")
conInd <- c(9)
conVars <- data[,conInd]
conVars <- data.frame(scale(conVars))
catVarsFac <- data[,c(1,2,3,4,5,6,7,8)]
catVarsFac[] <- lapply(catVarsFac, factor)
catVarsDum <- dummyCodeFactorDf(catVarsFac)
kamRes <- kamila(conVars, catVarsFac, numClust=5, numInit=10,
calcNumClust = "ps",numPredStrCvRun = 10, predStrThresh = 0.5)
summary(kamRes)
它说最好的簇数是 5。它是如何决定的,我可以看到指示这一点的图吗?
在 kamila
包文档中
Setting calcNumClust to ’ps’ uses the prediction strength method of Tibshirani & Walther (J. of Comp. and Graphical Stats. 14(3), 2005). There is no perfect method for estimating the number of clusters; PS tends to give a smaller number than, say, BIC based methods for large sample sizes.
在您使用它的情况下,您只为 numClust
指定了 一个 值。因此,看起来您实际上并没有 select 计算集群的数量 - 您已经选择了一个。
到select簇数,你要指定你感兴趣的范围,比如numClust = 2 : 7
还有select簇数的方法.
如果您还想 select 集群的数量,类似下面的方法可能会起作用。
kamRes <- kamila(conVars, catVarsFac, numClust = 2 : 7, numInit = 10,
calcNumClust = "ps", numPredStrCvRun = 10, predStrThresh = 0.5)
关于select簇数量的信息现在存在于
kamRes$nClust
,plot(2:7, kamRes$nClust$psValues)
可能就是您想要的。