【发布时间】:2023-11-29 08:02:02
【问题描述】:
我正在尝试使用计算每个点与其 k 个最近邻居之间的平均距离并生成 k 距离肘部图的技术来查找 eps 值,但我不知道如何在图上应用放大以查看肘部清晰,像这样: enter image description here 和 enter image description here
这是我的代码
neighbors = NearestNeighbors(n_neighbors=6)
neighbors_fit = neighbors.fit(data_scale)
distances, indices = neighbors_fit.kneighbors(data_scale)
print(distances)
distances = np.sort(distances, axis=0)
distances = distances[:,1]
plt.plot(distances)
plt.xlabel('Distance')
plt.ylabel('eps')
plt.title('Elbow Method For Optimal eps')
plt.show()
你能帮帮我吗?
【问题讨论】:
标签: python matplotlib plot nearest-neighbor euclidean-distance