def test_musae():
    """
    Testing the MUSAE node embedding.
    """
    graph = nx.newman_watts_strogatz_graph(50, 10, 0.2)

    features = {i: random.sample(range(150), 50) for i in range(50)}
    row = np.array([k for k, v in features.items() for val in v])
    col = np.array([val for k, v in features.items() for val in v])
    data = np.ones(50 * 50)
    shape = (50, 150)
    features = coo_matrix((data, (row, col)), shape=shape)

    model = MUSAE()
    model.fit(graph, features)
    embedding = model.get_embedding()

    assert embedding.shape[0] == graph.number_of_nodes()
    assert embedding.shape[1] == model.dimensions * (1 + model.window_size)
    assert type(embedding) == np.ndarray
Exemplo n.º 2
0
#------------------------------------
# MUSAE example
#------------------------------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.2)

X = {i: random.sample(range(150),50) for i in range(100)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
data = np.ones(100*50)
shape = (100, 150)

X = coo_matrix((data, (row, col)), shape=shape)

model = MUSAE()

model.fit(g, X)

model.get_memberships()

#--------------
# SINE example
#--------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.2)

X = {i: random.sample(range(150),50) for i in range(100)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
Exemplo n.º 3
0
#------------------------------------
# MUSAE example
#------------------------------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.2)

X = {i: random.sample(range(150),50) for i in range(100)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
data = np.ones(100*50)
shape = (100, 150)

X = coo_matrix((data, (row, col)), shape=shape)

model = MUSAE()

model.fit(g, X)

model.get_memberships()

#------------------------------------
# SINE example
#------------------------------------

g = nx.newman_watts_strogatz_graph(100, 10, 0.2)

X = {i: random.sample(range(150),50) for i in range(100)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
Exemplo n.º 4
0
"""MUSAE Example."""

import random
import numpy as np
import networkx as nx
from scipy.sparse import coo_matrix

from karateclub.node_embedding.attributed import MUSAE

g = nx.newman_watts_strogatz_graph(50, 10, 0.2)

X = {i: random.sample(range(150), 50) for i in range(50)}

row = np.array([k for k, v in X.items() for val in v])
col = np.array([val for k, v in X.items() for val in v])
data = np.ones(50 * 50)
shape = (50, 150)

X = coo_matrix((data, (row, col)), shape=shape)

model = MUSAE()

model.fit(g, X)