models.emb.node2vec

Module Contents

Classes

Node2vec

The node2vec model from the `”node2vec: Scalable feature learning for networks”

class models.emb.node2vec.Node2vec(dimension, walk_length, walk_num, window_size, worker, iteration, p, q)[source]

Bases: models.BaseModel

The node2vec model from the “node2vec: Scalable feature learning for networks” paper

Args:

hidden_size (int) : The dimension of node representation. walk_length (int) : The walk length. walk_num (int) : The number of walks to sample for each node. window_size (int) : The actual context size which is considered in language model. worker (int) : The number of workers for word2vec. iteration (int) : The number of training iteration in word2vec. p (float) : Parameter in node2vec. q (float) : Parameter in node2vec.

static add_args(parser)[source]

Add model-specific arguments to the parser.

classmethod build_model_from_args(cls, args)[source]

Build a new model instance.

train(self, G)[source]
_node2vec_walk(self, walk_length, start_node)[source]
_simulate_walks(self, num_walks, walk_length)[source]
_get_alias_edge(self, src, dst)[source]
_preprocess_transition_probs(self)[source]