DBSCAN Examples EMIS/CSE 8331 by Michael Hahsler # Two squares with different density

x <- rbind(
  cbind(x = runif(100, -2,2), y = runif(100, -2,2)),
  cbind(x = runif(200, 2.5,3.5), y = runif(200, -.5,.5))
)

plot(x)

k-means

cl <- kmeans(x, 2)
plot(x, col = cl$cluster)

PAM

library(cluster)
cl <- pam(x, 2)
plot(x, col = cl$cluster)