StackedNode2Vec

StackedNode2Vec([node_embeddings_size, ...])

Computes the Node2Vec representation of each node in a set of graphs.

StackedNode2Vec.fit(graphs)

Find the Node2Vec representation of each node for each graph.

StackedNode2Vec.get_embeddings()

Returns

StackedNode2Vec.get_dense_embeddings()

Returns

class graph_embeddings.algorithms.StackedNode2Vec(node_embeddings_size: int = 128, padding_value: int = 0, window: int = 5, walk_length: int = 100, n: int = 25, p: float = 1, q: float = 1, epochs: int = 10, algorithm: str = 'skip-gram', n_jobs: int = 1)[source]

Computes the Node2Vec representation of each node in a set of graphs.

Parameters
node_embeddings_size: int, default= 128

Size of the Node2Vec vector of each node

padding_value: int, default=0

This number fills the rows in the graph’s matrix, corresponding to a node that is not present in an individual graph

walk_length: int, default=100

Maximum length of each random walk

window: int, default=5

Maximum distance between the current and predicted word within a sentence.

n: int, default=25

Total number of random walks per root node

p: float, default=1

Defines probability, 1/p, of returning to source node

q: float, default=1

Defines probability, 1/q, for moving to a node away from the source node

epochs: int, default=10

Number of iterations (epochs) over the corpus

algorithm: str, {“skip-gram”, “CBOW”}

Training algorithm for Word2Vec.

n_jobs: int, default=1

Use these many worker threads to train the model (=faster training with multicore machines).

fit(graphs: List[Union[Graph, StellarGraph]])[source]

Find the Node2Vec representation of each node for each graph.

Parameters
graphs: List[Union[nx.classes.graph.Graph, StellarGraph]]

List of Networkx or StellarGraph objects

Returns
self: object

The whole StackedNode2Vec instance

get_dense_embeddings()[source]
Returns
embeddings: np.ndarray

Array with dimensions (n_graphs, n_nodes*node_embeddings_size, ) representing the flatten Node2Vec result of each node in each graph

get_embeddings()[source]
Returns
embeddings: np.ndarray

Array with dimensions (n_graphs, n_nodes, node_embeddings_size) representing the Node2Vec result of each node in each graph