This package is an updated version of the GEM package of palash1992. Key differences are:
- smaller codebase
- unittests (more to come)
- updated to current tensorflow and networkx version
Many physical systems in the world involve interactions between different entities and can be represented as graphs. Understanding the structure and analyzing properties of graphs are hence paramount to developing insights into the physical systems. Graph embedding, which aims to represent a graph in a low dimensional vector space, takes a step in this direction. The embeddings can be used for various tasks on graphs such as visualization, clustering, classification and prediction.
GEM
is a Python package which offers a general framework for graph embedding methods. It implements many state-of-the-art embedding techniques including Locally Linear Embedding, Laplacian Eigenmaps, Graph Factorization, Higher-Order Proximity preserved Embedding (HOPE), Structural Deep Network Embedding (SDNE) and node2vec. It is formatted such that new methods can be easily added for comparison. Furthermore, the framework implements several functions to evaluate the quality of obtained embedding including graph reconstruction, link prediction, visualization and node classification. It supports many edge reconstruction metrics including cosine similarity, euclidean distance and decoder based. For node classification, it defaults to one-vs-rest logistic regression classifier and supports other classifiers. For faster execution, C++ backend is integrated using Boost for supported methods. A paper showcasing the results using GEM
on various real world datasets can be accessed through Graph Embedding Techniques, Applications, and Performance: A Survey. The library is also published as GEM: A Python package for graph embedding methods.
Please refer https://palash1992.github.io/GEM/ to access the readme as a webpage.
Update: Note that this is a library for static graph embedding methods. For evolving graph embedding methods, please refer DynamicGEM. We also recently released Youtube dynamic graph data set which can be found at YoutubeGraph-Dyn.
The module was developed and is maintained by Palash Goyal.
GEM implements the following graph embedding techniques:
- Laplacian Eigenmaps
- Locally Linear Embedding
- Graph Factorization
- Higher-Order Proximity preserved Embedding (HOPE)
- Structural Deep Network Embedding (SDNE)
- node2vec
A survey of these methods can be found in Graph Embedding Techniques, Applications, and Performance: A Survey.
We store all graphs using the DiGraph as directed weighted graph in python package networkx. The weight of an edge is stored as attribute "weight". We save each edge in undirected graph as two directed edges.
The graphs are saved using nx.write_gpickle
in the networkx format and can be loaded by using nx.read_gpickle
.
- gem/embedding: existing approaches for graph embedding, where each method is a separate file
- gem/evaluation: evaluation tasks for graph embedding, including graph reconstruction, link prediction, node classification and visualization
- gem/utils: utility functions for graph manipulation, evaluation and etc.
- gem/data: input test graph (currently has Zachary's Karate graph)
- gem/c_src: source files for methods implemented in C++
- gem/c_ext: Python interface for source files in c_src using Boost.Python
nxt_gem is tested to work on Python 3.9
The required dependencies are: Numpy >= 1.12.0, SciPy >= 0.19.0, Networkx >= 2.4, Scikit-learn >= 0.18.1.
To run SDNE, GEM requires Theano >= 0.9.0 and tensorflow.
In case of Python 3, make sure it was compiled with ./configure --enable-shared
, and that you have /usr/local/bin/python
in your LD_LIBRARY_PATH
.
The package uses setuptools, which is a common way of installing python modules. To install in your home directory, use:
python setup.py install --user
To install for all users on Unix/Linux:
sudo python setup.py install
Or installing via pipwith git:
pip install git+https://github.com/jernsting/nxt_gem.git
See examples.
@article{goyal2017graph,
title = "Graph embedding techniques, applications, and performance: A survey",
journal = "Knowledge-Based Systems",
year = "2018",
issn = "0950-7051",
doi = "https://doi.org/10.1016/j.knosys.2018.03.022",
url = "http://www.sciencedirect.com/science/article/pii/S0950705118301540",
author = "Palash Goyal and Emilio Ferrara",
keywords = "Graph embedding techniques, Graph embedding applications, Python graph embedding methods GEM library"
}
@article{goyal3gem,
title={GEM: A Python package for graph embedding methods},
author={Goyal, Palash and Ferrara, Emilio},
journal={Journal of Open Source Software},
volume={3},
number={29},
pages={876}
}