我有这样的两个变量的嘈杂数据。
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")
仔细观察,我可以直观地看到潜在的 10 个集群。

然而,整个数据有很多点分布:
plot(x,y, pch = ".", col = "gray40")

我想做10个集群。我尝试了 K-means 聚类分析。
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-means,最近的邻居)可以对这种类型的数据做更多的正义。如果是这样,我该怎么做?