当我运行 kmeans 算法时,我收到此错误:
Error in kmeans(x, 2, 15) :
more cluster centers than distinct data points.
如何修复此错误,它是什么意思?我认为我的数据点是不同的?
这是我的文件和我用来生成 kmeans 的 r 代码:
rnames.csv :
"a1","a2","a3"
cells.csv :
0,1,2,1,4,3,5,3,4
cnames.csv :
"google","so","test"
cells = c(read.csv("c:\\data-files\\kmeans\\cells.csv", header = TRUE))
rnames = c(read.csv("c:\\data-files\\kmeans\\rnames.csv", header = TRUE))
cnames = c(read.csv("c:\\data-files\\kmeans\\cnames.csv", header = TRUE))
x <- matrix(cells, nrow=3, ncol=3, byrow=TRUE, dimnames=list(rnames, cnames))
# run K-Means
km <- kmeans(x, 2, 15)