Package: henhoe2vec
HeNHoE-2vecA Python implementation of the HeNHoE-2vec algorithm byValentini et al.for the embedding of networks with heterogeneous nodes and homogeneous edges (HeNHoE).Note: HeNHoE networks are analogous to multilayer networks: in HeNHoE networks, each node has a distinct node type, and in multilayer networks, each node belongs to a distinct layer. The termstypeandlayermay therefore be regarded synonymous. Throughout the code and for the remainder of this documentation, we will use the termsmultilayer networkandlayeras opposed toHeNHoE networkandtype.InstallationInstall the package from PyPI by running the following command:$ pip install henhoe2vecAlternatively, clone this repository by running$ git clone git@github.com:Bertr0/HeNHoE-2vec.gitand then install the package by runningpip install .from the root of the repository.UsageThis package may be used as a Python script or as a package, allowing its modules to be imported by other Python projects. Both forms of use make it easy to run HeNHoE-2vec on multilayer networks.As a PackageAfter installing the package usingpip, its modules may be imported usingimporthenhoe2vecThe many individual steps of HeNHoE-2vec are accumulated in a singlerun()method in thehenhoe2vec.henhoe2vecmodule. HeNHoE-2vec can be run from start to finish as follows:importhenho2vecashh2vhh2v.henhoe2vec.run(input_csv,output_dir)input_csvis the path to the multilayer edge list of the network to be embedded (csv file with no index).output_diris the path to the output directory where the embedding files will be saved. Therun()method takes a bunch of other optional parameters which can be used to configure HeNHoE-2vec. A comprehensive overview of parameters can be found in the code documentation.As a Python ScriptTo run HeNHoE-2vec as a script, clone this repository using$ git clone git@github.com:Bertr0/HeNHoE-2vec.git, install the requirements found inrequirements.txtand run the following command from the root of the repository:$ python3 -m src.henhoe2vec --input <input_path> --output_dir <output_dir_path>This will generate node embeddings for the nodes of the network specified by the multilayer edge list saved at<input_path>and saves the embedding files in<output_dir>.Runpython3 -m src.henhoe2vec --helpfrom the root of the repository to show an overview of all arguments taken by the script. The following table also shows an overview of all arguments:Script ArgumentsArgumentTypeDescriptionDefault Value--inputstrPath to the multilayer edge list of the network to be embedded (csv file with no index).---sepstrDelimiter of the input csv edge list."\t"--headerstore_truePass this argument if the input csv edge list has a header.---output_namestrName of the output .csv file (without suffix)."embeddings"--is_directedstore_truePass this argument if the network is directed.---edges_are_distancesstore_truePass this argument if edge weights indicate distance between nodes (opposed to weight/similarity).---output_dirstrPath of the output directory where the embedding files will be saved.---dimensionsintThe dimensionality of the embeddings.128--walk_lengthintLength of each random walk.20--num_walksintNumber of random walks to simulate for each node.10--pfloatReturn parameterpfrom the node2vec algorithm.1.0--qfloatIn-out parameterqfrom the node2vec algorithm.0.5--sfloatDefault switching parameter for layer pairs which are not specified in the--s-dictargument.1.0--s_dictlistSwitching parameters for specific layer pairs in a dict-like manner. Pass the names of layer pairs followed by their switching parameters, separated by white spaces. E.g., if the switching parameter fromlayer1tolayer2is0.5and the switching parameter fromlayer2tolayer1is0.7, you would passlayer1 layer2 0.5 layer2 layer1 0.7. Note that layer pairs are directed. For all layer pairs which are not specified here, the default parameter--sis adopted.empty list--window_sizeintContext size for the word2vec optimization.10--epochsintNumber of epochs in SGD.1--workersintNumber of parallel workers (threads).8