def spectral(k,D, rs):
"""
From clustering_on_transcript_compatibility_counts, see github for MIT license
"""
if D[1,1] < 1: D = 1-D # Convert distance to similarity matrix
spectral = cluster.SpectralClustering(n_clusters=k,affinity='precomputed', random_state=rs)
spectral.fit(D)
labels = spectral.labels_
return labels
# gets max weight matching of a biparetite graph with row_label x column_label
# (weights are given by weight_matrix)
评论列表
文章目录