dtw_templates.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:DTW_physionet2016 作者: JJGO 项目源码 文件源码
def cluster(aff_matrix, records, n_clusters, medoid_indexes):
    Cluster = SpectralClustering(n_clusters=n_clusters, affinity='precomputed')
    labels = Cluster.fit_predict(aff_matrix)

    medoid_indexes = medoid_indexes.loc[records]

    t_records = []
    indexes = []

    for i in range(n_clusters):
        labels_i = np.where(labels == i)[0]
        sub_aff_matrix = aff_matrix[labels_i, :][:, labels_i]
        medoid_index   = np.argmax(np.prod(sub_aff_matrix, axis=0))
        absolute_index = labels_i[medoid_index]
        r = medoid_indexes.index[absolute_index]
        t_records.append(r)
        i = medoid_indexes.iloc[absolute_index].values[0]
        indexes.append(i)
    return t_records, indexes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号