I need to use DBSCAN for my research and am having trouble understanding the kdist graph used to select the epsilon parameter - specifically, I do not understand what is happening behind the scenes and what is being presented on the X axis. I am using R and the DBSCAN library.

I am currently just trying to understand the help presented in the documentation when I run the following code:


This is the sample code:

iris <- as.matrix(iris[,1:4])

kNNdist(iris, k=4, search="kd")
kNNdistplot(iris, k=4)
## the knee is around a distance of .5

Which produces the following output:

My questions:

  1. The 'iris' object is a matrix containing four columns of 150 observations. I am very confused as to what 'distance' the algorithm is calculating given the number of columns present. Which one is it using? When I think of distance, I think of calculating the distance between two points (in my case, typically lat/long) using the standard formula:

$\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$

Which is clearly not what's going on here as when I test the kNNdist function on a subset of the iris matrix containing only one column, it still produces a result. Is there another definition of 'neighbor' that I am just completely not understanding here?

  1. I also do not understand the X axis - what does 'Points (sample) sorted by distance' mean?

  2. The data set that I ultimately need to run DBSCAN on is spatial (lat/long) - does this change how epsilon would be calculated?

  3. My background is in geography, and I'm slowly starting to move towards the more quantitative side of things, so I tend to think spatially. When this package is referring to 'neighbor', what exactly do they mean? I tend to think of neighbors as points nearby in space, i.e. lat/long that are close together.

Thanks in advance for any help. I'm sure this is probably a simple concept that is flying about 10,000 feet above my head.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.