def plot_clusters_igraph(responsibilities, color_groups):
from scipy.spatial.distance import pdist, correlation, squareform
from igraph import Graph, plot
data = responsibilities[:, :2]
Y = pdist(data, hellinger_distance)
print(Y[:30], file=stderr)
# return
g = Graph()
n = data.shape[0]
g.add_vertices(n)
colors = ["grey"]*n
palette = list(colors_dict.values())
for j, group in enumerate(color_groups):
c = palette[j]
for i in group:
colors[i] = c
l = g.layout_mds(dist=squareform(Y))
plot(g, layout=l, vertex_color=colors, bbox=(1024, 1024), vertex_size=5)
# c&p from stackexchange
评论列表
文章目录