Skip to main content

nxt_gem: A Python module for Graph Embedding Methods

Project description

Python application Coverage Status Quality Gate Status

nxt_gem: Graph Embedding Methods

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

GEM: Graph Embedding Methods

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.

Implemented Methods

GEM implements the following graph embedding techniques:

A survey of these methods can be found in Graph Embedding Techniques, Applications, and Performance: A Survey.

Graph Format

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.

Repository Structure

  • 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

Dependencies

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.

Install

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

Usage

See examples.

Cite

@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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nxt_gem-2.0.3.tar.gz (15.6 MB view details)

Uploaded Source

Built Distribution

nxt_gem-2.0.3-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file nxt_gem-2.0.3.tar.gz.

File metadata

  • Download URL: nxt_gem-2.0.3.tar.gz
  • Upload date:
  • Size: 15.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for nxt_gem-2.0.3.tar.gz
Algorithm Hash digest
SHA256 9c05e462f1b7f571d564b75313d5c735b9aed2a05d0e3d79169efa997b0dacc1
MD5 8434c414a7562d2ac61aeb23e2cfaaf0
BLAKE2b-256 4bee4bbe680bf59578d6cca679e121dd44cfbf918a64b45877c8c1fdc9003ecc

See more details on using hashes here.

File details

Details for the file nxt_gem-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: nxt_gem-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for nxt_gem-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d44d86b3f364ecda0879f6be51e5c2bfa582f9d2a661f83e6c97342a306fcd5
MD5 bd6978e485eb89b4b396fc1fd72b7665
BLAKE2b-256 e613648a1bf0cf0243a1aba8ba065541533b0410fad30e7653fab1722ebaf2de

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page