I have the following code to estimate the eps
for DBSCAN. If the code is fine then I have obtained the knn distance plot
. The code is :
ns = 4
nbrs = NearestNeighbors(n_neighbors=ns).fit(data)
distances, indices = nbrs.kneighbors(data)
distanceDec = sorted(distances[:,ns-1], reverse=True)
plt.plot(indices[:,0], distanceDec)
Where data
is the array of pixel locations (rows and columns). I have obtained a plot but I am not getting how do I determine the eps
. According to DBSCAN
paper,
the threshold point is the first point in the first valley of the sorted k-dist graph
I dont know how do I implement it in the code. Moreover, is ns = 4
is my minPts
or is there any way to estimate minPts
from eps
?
Use
plt.plot(list(range(1,noOfPointsYouHave+1)), distanceDec)
You'll get an elbow plot. The distance where you have a sharp change in curve is your epsilon.
You can also make reverse=False, if you wish.
As far as I can tell, this is to be determined visually by a human.
Automation doesn't seem to work.
Or you can use OPTICS.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.