Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

StellarGraph Machine Learning library logo

Stellar Graph Machine Learning Library

Code style: black

Build Status

Branch Build
master Build status
devel Build status

StellarGraph is a Python library for machine learning on graph-structured (or equivalently, network-structured) data.

Graph-structured data represent entities, e.g., people, as nodes (or equivalently, vertices), and relationships between entities, e.g., friendship, as links (or equivalently, edges). Nodes and links may have associated attributes such as age, income, time when a friendship was established, etc. StellarGraph supports analysis of both homogeneous networks (with nodes and links of one type) and heterogeneous networks (with more than one type of nodes and/or links).

The StellarGraph library implements several state-of-the-art algorithms for applying machine learning methods to discover patterns and answer questions using graph-structured data.

The StellarGraph library can be used to solve tasks using graph-structured data, such as:

  • Representation learning for nodes and edges, to be used for visualisation and various downstream machine learning tasks
  • Node classification and attribute inference
  • Link prediction

We provide examples of using StellarGraph to solve such tasks using several real-world datasets.

Guiding Principles

StellarGraph uses Keras library, and adheres to the same guiding principles as Keras: user friendliness, modularity, and easy extendability. Modules and layers of StellarGraph library are designed so that they can be used together with standard Keras layers and modules, if required. This enables flexibility in using existing, or creating new models and workflows for machine learning on graphs.

Getting Started

To get started with StellarGraph you'll need data structured as homogeneous or heterogeneous graph, including attributes for the entities represented as graph nodes. NetworkX is used to represent the graph and Pandas or Numpy are used to store node attributes.

Detailed and narrated examples of various machine learning workflows on network data, supported by StellarGraph, from data ingestion into graph structure to inference, are given in /demos.

Installation

StellarGraph is a Python 3 library and requires Python version 3.6 to function (note that the library uses Keras with the Tensorflow backend, and thus does not currently work in python 3.7). The required Python version can be downloaded and installed from python.org. Alternatively, use the Anaconda Python environment, available from anaconda.com.

The StellarGraph library can be installed in one of two ways, described next.

Install StellarGraph from PyPy:

To install StellarGraph library from PyPy using pip, run the following command:

pip install stellargraph

Install StellarGraph from Github source:

First, clone StellarGraph using git:

git clone https://github.com/stellargraph/stellargraph/

Then, cd to StellarGraph folder, install requirements and the library:

cd stellargraph
pip install -r requirements.txt
pip install -e .

Algorithms

The StellarGraph library currently includes the following algorithms for graph machine learning:

  • GraphSAGE [1]

    • Supports representation learning, node classification/regression, and link prediction for homogeneous networks. The current implementation supports mean aggregation of neighbour nodes only.
  • HinSAGE

    • Extension of GraphSAGE algorithm to heterogeneous networks. Supports representation learning, node classification/regression, and link prediction/regression for heterogeneous graphs. The current implementation supports mean aggregation of neighbour nodes, taking into account their types and the types of links between them.
  • Node2Vec [2]

    • Unsupervised representation learning for homogeneous networks, taking into account network structure while ignoring node attributes. The node2vec algorithm is implemented by combining StellarGraph's random walk generator with the word2vec algorithm from Gensim. Learned node representations can be used in downstream machine learning models implemented using Scikit-learn, Keras, Tensorflow or any other Python machine learning library.
  • Metapath2Vec [3]

    • Unsupervised, metapath-guided representation learning for heterogeneous networks, taking into account network structure while ignoring node attributes. The implementation combines StellarGraph's metapath-guided random walk generator and Gensim word2vec algorithm. As with node2vec, the learned node representations (node embeddings) can be used in downstream machine learning models to solve tasks such as node classification, link prediction, etc, for heterogeneous networks.

Getting Help

API Documentation for StellarGraph can be found here.

CI

buildkite integration

Pipeline is defined in .buildkite/pipeline.yml

Docker images

  • Tests: Uses the official python:3.6 image.
  • Style: Uses black from the stellargraph docker hub organisation.

References

  1. Inductive Representation Learning on Large Graphs. W.L. Hamilton, R. Ying, and J. Leskovec arXiv:1706.02216 [cs.SI], 2017. (link)

  2. Node2Vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 2016. (link)

  3. Metapath2Vec: Scalable Representation Learning for Heterogeneous Networks. Yuxiao Dong, Nitesh V. Chawla, and Ananthram Swami. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 135–144, 2017 (link)

Release files for stellargraph 0.4.0b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stellargraph 0.4.0b0
File Size Uploaded
stellargraph-0.4.0b0.tar.gz 63.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stellargraph 0.4.0b0
File Interpreter ABI Platform
stellargraph-0.4.0b0-py3-none-any.whl Python 3 none any Details

Total release size: 369.0 kB

Release files / stellargraph-0.4.0b0.tar.gz

Download URL stellargraph-0.4.0b0.tar.gz
Size 63.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1e920d6e43a79a67cf4b83077c79115f19605c63408a447685520c919113df92
BLAKE2b-256 checksum
How to use checksums
5b647878ab12ea12b65cfc85d89a19f2fdff8d3cb451b17b4b37f841c740087b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Release files / stellargraph-0.4.0b0-py3-none-any.whl

Download URL stellargraph-0.4.0b0-py3-none-any.whl
Size 305.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cfe10aa66bcb0966404dcdbcce94bf299795cdddaca32fcc516e44193024ef7
BLAKE2b-256 checksum
How to use checksums
fac3317177ae5e52bf48ef217d04dab56d64755589397fece96a9568b31f41ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page