我有两个这样的变量的嘈杂数据。
x1 <- rep(seq(0,1, 0.1), each = 3000)
set.seed(123)
y1 <- rep (c(0.2, 0.8, 0.3, 0.9, 0.65, 0.35,0.7,0.1,0.25, 0.3, 0.95), each = 3000)
set.seed(1234)
e1 = rnorm(length(x1), 0.07,0.07)
set.seed(1223)
e2 = rnorm(length(x1), 0.07,0.07)
set.seed(1334)
yn <- rnorm(20000, 0.5,0.9)
set.seed(2344)
xn <- rnorm(20000, 0.5,0.9)
y <- c(y1 + e1,yn)
x <- c(x1 + e2, xn)
plot(x,y, xlim=c(0,1.2), ylim = c(0,1.2), pch = ".", col = "gray40")
我可以从视觉上看到有近十个潜在的簇。
但是,整个数据有很多要点:
plot(x,y, pch = ".", col = "gray40")
我想做10个集群。我尝试了K-均值聚类分析。
xm1 <- cbind(x,y)
cl1 <- kmeans(xm1, 10)
colrs <- c("red", "green", "blue1", "pink", "green4","tan",
"gray40", "yellow", "black", "purple")
plot(xm1, col = colrs[cl1$cluster], pch = ".", xlim=c(0,1.2), ylim = c(0,1.2))
plot(xm1, col = colrs[cl1$cluster], pch = ".")
无论如何,是否存在(可能是核k均值,最近的邻居)可以对此类数据做更多的判断。如果可以,我该怎么做?
1
到目前为止,您有什么问题?为什么您所拥有的(k均值聚类分析)不可接受?
—
史蒂夫S
看看到DBSCAN或光学算法(参见en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/...)
—
乔治Spedicato