easygraph.functions.graph_embedding package
Submodules
easygraph.functions.graph_embedding.NOBE module
- easygraph.functions.graph_embedding.NOBE.NOBE(G, K)[source]
Graph embedding via NOBE[1].
- Parameters
G (easygraph.Graph) – An unweighted and undirected graph.
K (int) – Embedding dimension k
- Returns
Y – list of embedding vectors (y1, y2, · · · , yn)
- Return type
list
Examples
>>> NOBE(G,K=15)
References
- easygraph.functions.graph_embedding.NOBE.NOBE_GA(G, K)[source]
Graph embedding via NOBE-GA[1].
- Parameters
G (easygraph.Graph) – An unweighted and undirected graph.
K (int) – Embedding dimension k
- Returns
Y – list of embedding vectors (y1, y2, · · · , yn)
- Return type
list
Examples
>>> NOBE_GA(G,K=15)
References
easygraph.functions.graph_embedding.deepwalk module
- easygraph.functions.graph_embedding.deepwalk.deepwalk(G, dimensions=128, walk_length=80, num_walks=10, **skip_gram_params)[source]
Graph embedding via DeepWalk.
- Parameters
G (easygraph.Graph or easygraph.DiGraph) –
dimensions (int) – Embedding dimensions, optional(default: 128)
walk_length (int) – Number of nodes in each walk, optional(default: 80)
num_walks (int) – Number of walks per node, optional(default: 10)
skip_gram_params (dict) – Parameters for gensim.models.Word2Vec - do not supply size, it is taken from the dimensions parameter
- Returns
embedding_vector (dict) – The embedding vector of each node
most_similar_nodes_of_node (dict) – The most similar nodes of each node and its similarity
Examples
>>> deepwalk(G, ... dimensions=128, # The graph embedding dimensions. ... walk_length=80, # Walk length of each random walks. ... num_walks=10, # Number of random walks. ... skip_gram_params = dict( # The skip_gram parameters in Python package gensim. ... window=10, ... min_count=1, ... batch_words=4, ... iter=15 ... ))
References
easygraph.functions.graph_embedding.line module
easygraph.functions.graph_embedding.net_emb_example_citeseer module
easygraph.functions.graph_embedding.node2vec module
- easygraph.functions.graph_embedding.node2vec.node2vec(G, dimensions=128, walk_length=80, num_walks=10, p=1.0, q=1.0, weight_key=None, workers=None, **skip_gram_params)[source]
Graph embedding via Node2Vec.
- Parameters
G (easygraph.Graph or easygraph.DiGraph) –
dimensions (int) – Embedding dimensions, optional(default: 128)
walk_length (int) – Number of nodes in each walk, optional(default: 80)
num_walks (int) – Number of walks per node, optional(default: 10)
p (float) – The return hyper parameter, optional(default: 1.0)
q (float) – The input parameter, optional(default: 1.0)
weight_key (string or None (default: None)) – On weighted graphs, this is the key for the weight attribute
workers (int or None, optional(default : None)) – The number of workers generating random walks (default: None). None if not using only one worker.
skip_gram_params (dict) – Parameters for gensim.models.Word2Vec - do not supply ‘size’, it is taken from the ‘dimensions’ parameter
- Returns
embedding_vector (dict) – The embedding vector of each node
most_similar_nodes_of_node (dict) – The most similar nodes of each node and its similarity
Examples
>>> node2vec(G, ... dimensions=128, # The graph embedding dimensions. ... walk_length=80, # Walk length of each random walks. ... num_walks=10, # Number of random walks. ... p=1.0, # The `p` possibility in random walk in [1]_ ... q=1.0, # The `q` possibility in random walk in [1]_ ... weight_key='weight', ... skip_gram_params=dict( # The skip_gram parameters in Python package gensim. ... window=10, ... min_count=1, ... batch_words=4 ... ))
References