mowl.walking

Walking

class mowl.walking.walking.WalkingModel(num_walks, walk_length, outfile, workers=1)[source]

Bases: object

Parameters
  • num_walks (int) – Number of walks per node

  • walk_length (int) – Length of each walk

  • workers (int, optional) – Number of threads to be used for computing the walks, defaults to 1’

walk(edges, nodes_of_interest=None)[source]

This method will generate random walks from a graph in the form of edgelist.

Parameters
  • edges (mowl.projection.edge.Edge) – List of edges

  • nodes_of_interest (list, optional) – List of entity names to filter the generated walks. If a walk contains at least one word of interest, it will be saved into disk, otherwise it will be ignored. If no list is input, all the nodes will be considered. Defaults to None

Changed in version 0.1.0: The method now can accept a list of entities to focus on when generating the random walks.

DeepWalk

class mowl.walking.deepwalk.model.DeepWalk(num_walks, walk_length, alpha=0.0, outfile=None, workers=1, seed=0)[source]

Bases: WalkingModel

Implementation of DeepWalk based on <https://github.com/phanein/deepwalk/blob/master/deepwalk/graph.py>

Parameters

alpha (float, optional) – Probability of restart, defaults to 0

walk(edges, nodes_of_interest=None)[source]

Changed in version 0.1.0: The method now can accept a list of entities to focus on when generating the random walks.

Node2Vec

class mowl.walking.node2vec.model.Node2Vec(num_walks, walk_length, p=1, q=1, outfile=None, workers=1)[source]

Bases: WalkingModel

Parameters
  • p (float) – Return hyperparameter. Default is 1.

  • q (float) – In-out hyperparameter. Default is 1.

walk(edges, nodes_of_interest=None)[source]

This method will generate random walks from a graph in the form of edgelist.

Parameters
  • edges (mowl.projection.edge.Edge) – List of edges

  • nodes_of_interest (list, optional) – List of entity names to filter the generated walks. If a walk contains at least one word of interest, it will be saved into disk, otherwise it will be ignored. If no list is input, all the nodes will be considered. Defaults to None

Changed in version 0.1.0: The method now can accept a list of entities to focus on when generating the random walks.