我已经应用DBSCAN在一个数据集上执行聚类,该数据集由点云中每个点的X、Y和Z坐标组成。我只想绘制少于100个点的簇。到目前为止,我的情况是:
clustering = DBSCAN(eps=0.1, min_samples=20, metric='euclidean').fit(only_xy)
plt.scatter(only_xy[:, 0], only_xy[:, 1],
c=clustering.labels_, cmap='rainbow')
clusters = clustering.components_
#Store the labels
labels = clustering.labels_
#Then get the frequency count of the non-negative labels
counts = np.bincount(labels[labels>=0])
print(counts)
Output:
[1278 564 208 47 36 30 191 54 24 18 40 915 26 20
24 527 56 677 63 57 61 1544 512 21 45 187 39 132
48 55 160 46 28 18 55 48 35 92 29 88 53 55
24 52 114 49 34 34 38 52 38 53 69]
所以我找到了每个簇中的点数,但是我不知道如何只选择少于100个点的簇。你知道吗
我想如果你运行这个代码,你可以得到标签,和集群的组件,集群的大小超过100:
您可以找到计数小于100的标签索引:
然后,您可以将结果索引应用于您的DBSCAN结果和标签,例如(或多或少):
相关问题 更多 >
编程相关推荐