Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def xy_embeddings(_graph):
- graph = _graph.copy()
- ### BEGIN SOLUTION
- pbar = tqdm(total=4)
- model = LaplacianEigenmaps(dimensions=16)
- model.fit(graph)
- laplacian_emb = model.get_embedding()
- model = PCA(n_components=2)
- model.fit(laplacian_emb)
- laplacian_emb = model.transform(laplacian_emb)
- pbar.update(1)
- A = nx.to_numpy_array(graph)
- model = TruncatedSVD(n_components=16)
- model.fit(A)
- svd_emb = model.transform(A)
- model = PCA(n_components=2)
- model.fit(svd_emb)
- svd_emb = model.transform(svd_emb)
- pbar.update(1)
- model = DeepWalk(
- walk_number=10, walk_length=30, dimensions=16, window_size=10)
- model.fit(graph)
- deep_walk_emb = model.get_embedding()
- model = PCA(n_components=2)
- model.fit(deep_walk_emb)
- deep_walk_emb = model.transform(deep_walk_emb)
- pbar.update(1)
- model = MeanWalklets(
- walk_number=10, walk_length=30, dimensions=16, window_size=10)
- model.fit(graph)
- walklets_emb = model.get_embedding()
- model = PCA(n_components=2)
- model.fit(walklets_emb)
- walklets_emb = model.transform(walklets_emb)
- pbar.update(1)
- pbar.close()
- return laplacian_emb, svd_emb, deep_walk_emb, walklets_emb
- ### END SOLUTION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement