关于 kmeans 聚类的 wikibook ( http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/K-Means ) 给出了一个示例聚类分析:
是否可以修改代码以便从每个集群中生成一个标签?下图不表示正在比较的内容。共有三个集群,但每个集群的名称是什么?
这是生成图表的代码:
# import data (assume that all data in "data.txt" is stored as comma separated values)
x <- read.csv("data.txt", header=TRUE, row.names=1)
# run K-Means
km <- kmeans(x, 3, 15)
# print components of km
print(km)
# plot clusters
plot(x, col = km$cluster)
# plot centers
points(km$centers, col = 1:2, pch = 8)