在DBSCAN中利用knn距离图估计eps

2024-10-05 14:29:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码来估计DBSCAN的eps。如果代码没问题,那么我就得到了knn distance plot。代码是:

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)

其中data是像素位置的数组(行和列)。我得到了一个图,但我不知道如何确定eps。根据DBSCAN论文

the threshold point is the first point in the first valley of the sorted k-dist graph

我不知道如何在代码中实现它。而且,ns = 4是我的minPts还是有什么方法可以从eps来估计{}?在


Tags: the代码dataplotepsdbscanpointfirst
2条回答

使用

plt.plot(list(range(1,noOfPointsYouHave+1)), distanceDec)

你会得到一个肘击图。曲线发生剧烈变化的距离就是epsilon。在

如果愿意,也可以将reverse=False设置为False。在

据我所知,这是由人类通过视觉来确定的。在

自动化似乎不起作用。在

或者你可以用光学仪器。在

相关问题 更多 >