MCPcopy
hub / github.com/shenweichen/GraphEmbedding / plot_embeddings

Function plot_embeddings

examples/line_wiki.py:36–53  ·  view source on GitHub ↗
(embeddings, label_path, show=True)

Source from the content-addressed store, hash-verified

34
35
36def plot_embeddings(embeddings, label_path, show=True):
37 x_data, y_data = read_node_label(str(label_path))
38
39 embedding_list = np.array([embeddings[node] for node in x_data])
40 node_pos = TSNE(n_components=2).fit_transform(embedding_list)
41
42 color_idx = {}
43 for index, label in enumerate(y_data):
44 color_idx.setdefault(label[0], [])
45 color_idx[label[0]].append(index)
46
47 for label, indexes in color_idx.items():
48 plt.scatter(node_pos[indexes, 0], node_pos[indexes, 1], label=label)
49 plt.legend()
50 if show:
51 plt.show()
52 else:
53 plt.close()
54
55
56def main(smoke=False, show=True):

Callers 1

mainFunction · 0.70

Calls 1

read_node_labelFunction · 0.90

Tested by

no test coverage detected