data("DS3")
# use a shared neighborhood of 20 points and require 12 shared neighbors
cl <- jpclust(DS3, k = 20, kt = 12)
cl
plot(DS3, col = cl$cluster+1L, cex = .5)
# Note: JP clustering does not consider noise and thus,
# the sine wave points chain clusters together.
# use a precomputed kNN object instead of the original data.
nn <- kNN(DS3, k = 30)
nn
cl <- jpclust(nn, k = 20, kt = 12)
cl
# cluster with noise removed (use low pointdensity to identify noise)
d <- pointdensity(DS3, eps = 25)
hist(d, breaks = 20)
DS3_noiseless <- DS3[d > 110,]
cl <- jpclust(DS3_noiseless, k = 20, kt = 10)
cl
plot(DS3_noiseless, col = cl$cluster+1L, cex = .5)
Run the code above in your browser using DataLab