我希望对几个时间戳(以分钟为单位)进行聚类。 到目前为止我所做的是:
1)将点转换为弧度
#points containing time value in minutes
points = [100, 200, 600, 659, 700]
def convert_to_radian(x):
return((x / (24 * 60)) * 2 * pi)
rad_function = np.vectorize(convert_to_radian)
points_rad = rad_function(points)
2)生成距离矩阵
^{pr2}$3)指定距每个点的最短距离
dist[((dist > pi) & (dist <= (2*pi)))] = dist[((dist > pi) & (dist <= (2*pi)))] -(2*pi)
dist[((dist > (-2*pi)) & (dist <= (-1*pi)))] = dist[((dist > (-2*pi)) & (dist <= (-1*pi)))] + (2*pi)
dist = abs(dist)
现在我想在距离矩阵上使用DBSCAN,如何将其聚类到弧度距离?在
谢谢你!在
好吧,经过大量的挖掘之后,我意识到我可以简单地将DBSCAN metric设置为“precomputed”,使用
.fit()
方法并传入我的距离矩阵。对于那些感兴趣的人,这里是来源:输出:
^{pr2}$相关问题 更多 >
编程相关推荐