为新数据点预测球形k-Means聚类

时间:2015-03-13 10:27:43

标签: r cluster-analysis prediction

我正在使用skmeans包在R中执行球形k-Means聚类。我的目标是使用中等数量的验证数据点来定义集群,然后将所有其余数据点分配给这些集群。

据我所知,这可以使用' cl_predict'功能在' clue'包。出于某种原因,输出都是NA。有谁知道如何做到这一点?

这是一个小例子(要聚类的真实数据包括大约200万个观测值和50个变量)。

#invoke necessary packages
library("skmeans")
library("clue")
#generate test data
testGrid<-(seq(-10,10,by=1)) 
pointsToCluster<-merge(data.frame(x=testGrid[-11]),
data.frame(y=testGrid[-11]))
plot(pointsToCluster)
#perform spherical clustering
sClustOut<-skmeans(as.matrix(pointsToCluster[,1:2]),4)
plot(pointsToCluster,col=sClustOut$cluster)
#predict clusters for new data points
newDataPoints<-matrix(c(1.3,2.1,3.1,5.9),ncol=2)
cl_predict(sClustOut,newDataPoints)

0 个答案:

没有答案
相关问题