yes, DBSCAN parameters, and in particular the parameter eps (size of the epsilon neighborhood). In the documentation we have a "Look for the knee in the plot".
Fine, but it requires a visual analysis. And it doesn't really work if we want to make things automatic. So, I was wondering if it was possible to find a good eps in a few lines of code.
Let's imagine something like :
- evaluate kNN distance
- sort these values
- scale them (so that the values are always between 0 and 1)
- evaluate the derivative
- find the first point where derivative is higher than a certain value, let's try with 1
In R, it would look like (using iris dataset as in the DBSCAN documentation) :
# evaluate kNN distance dist <- dbscan::kNNdist(iris, 4) # order result dist <- dist[order(dist)] # scale dist <- dist / max(dist) # derivative ddist <- diff(dist) / ( 1 / length(dist)) # get first point where derivative is higher than 1 knee <- dist[length(ddist)- length(ddist[ddist > 1])]
Is this approach relevant or totally nonsense ?