GraphSAGE supervised (AGA-only)

This algorithm is only available in Aura Graph Analytics.

Glossary

Directed

Directed trait. The algorithm is well-defined on a directed graph.

Directed

Directed trait. The algorithm ignores the direction of the graph.

Directed

Directed trait. The algorithm does not run on a directed graph.

Undirected

Undirected trait. The algorithm is well-defined on an undirected graph.

Undirected

Undirected trait. The algorithm ignores the undirectedness of the graph.

Heterogeneous nodes

Heterogeneous nodes fully supported. The algorithm has the ability to distinguish between nodes of different types.

Heterogeneous nodes

Heterogeneous nodes allowed. The algorithm treats all selected nodes similarly regardless of their label.

Heterogeneous relationships

Heterogeneous relationships fully supported. The algorithm has the ability to distinguish between relationships of different types.

Heterogeneous relationships

Heterogeneous relationships allowed. The algorithm treats all selected relationships similarly regardless of their type.

Weighted relationships

Weighted trait. The algorithm supports a relationship property to be used as weight, specified via the relationshipWeightProperty configuration parameter.

Weighted relationships

Weighted trait. The algorithm treats each relationship as equally important, discarding the value of any relationship weight.

Node properties

Node properties trait. The algorithm makes use of node properties.

Introduction

GraphSAGE is a graph neural network (GNN) architecture outlined in the paper Inductive Representation Learning on Large Graphs by Hamilton et al. (2017).

This section covers the syntax used to execute the GraphSAGE algorithm supervised to predict labels of nodes in a graph.

For node embeddings, see GraphSAGE unsupervised.
GraphSAGE supervised syntax per mode
Run GraphSAGE supervised in train mode on a named graph.
CALL gds.graphSage.supervised.train(
  graphName: String,
  configuration: Map
)
YIELD
  preProcessingMillis: Integer,
  trainMillis: Integer,
  configuration: Map
Table 1. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 2. Configuration
Name Type Default Optional Description

activationFunction

String

"relu"

yes

The activation function to use. Valid values are "relu" and "sigmoid"

aggregator

String

"mean"

yes

The neighborhood embedding aggregator to use. Valid values are "mean" and "max"

batchSize

Integer

n/a

yes

The number of target nodes to train on in each batch. If not provided, the algorithm will automatically infer the maximally allowed batch size within the constraints of available memory

classWeights

Boolean

false

yes

Whether to use class weights to balance the training data. If set to true, class weights will be calculated based on the distribution of the target labels in the training set.

dropout

Float

0.1

yes

The dropout probability for each layer. Must be a value >= 0.0 and < 1.0

embeddingDimension

Integer

256

yes

The node embedding dimension of the model layers' outputs

epochs

Integer

n/a

no

The number of epochs to train the model

epochsPerVal

Integer

0

yes

The number of epochs between evaluating the model on the validation set. If set to 0, the model will not be evaluated on the validation set

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

layerNormalization

Boolean

true

yes

Whether to apply layer normalization between the model layers

learningRate

Float

0.001

yes

The learning rate for the optimizer

modelName

String

n/a

no

The name of the model to train (must be unique)

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels.

numNeighbors

List

[20, 10]

yes

The number of neighbors to sample for each layer. Note that this also determines the number of layers

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

splitRatios

Map

{"TRAIN" 0.6, "TEST" 0.2, "VALID" 0.2}

yes

The ratios as a map to split the target nodes of the input graph into training, test, and validation sets. The keys must be "TRAIN", "TEST" and "VALID". The sum of the values must be 1.0

targetLabel

String

n/a

no

The node label (i.e. type) to train to predict on

targetProperty

String

n/a

no

The node property to train to predict, represented by a column in the input node table of the specified 'target_label'.

Table 3. Results
Name Type Description

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

trainMillis

Integer

Milliseconds to train the model.

configuration

Map

The configuration used for running the algorithm.

Run GraphSAGE supervised in stream mode on a named graph.
CALL gds.graphSage.supervised.stream(
  graphName: String,
  configuration: Map
)
YIELD
  nodeId: Integer,
  predictedClass: Integer,
  predictedProbabilities: List
Table 4. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 5. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE supervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

Table 6. Results
Name Type Description

nodeId

Integer

Node ID.

predictedClass

Integer

Predicted class for this node.

predictedProbabilities

List of Float

Probabilities for all classes, for this node.

Run GraphSAGE supervised in mutate mode on a graph stored in the catalog.
CALL gds.graphSage.supervised.mutate(
  graphName: String,
  configuration: Map
)
YIELD
  computeMillis: Integer,
  mutateMillis: Integer,
  nodePropertiesWritten: Integer,
  preProcessingMillis: Integer,
  configuration: Map
Table 7. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 8. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE supervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

mutateProperty

String

n/a

no

The node property in the GDS graph to which the embedding is written.

predictedProbabilityProperty

String

n/a

yes

The node property in which the class probability list is stored. If omitted, the probability list is discarded.

Table 9. Results
Name Type Description

computeMillis

Integer

Milliseconds for running the algorithm.

mutateMillis

Integer

Milliseconds for adding properties to the projected graph.

nodePropertiesWritten

Integer

Number of properties added to the projected graph.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

configuration

Map

The configuration used for running the algorithm.

Run GraphSAGE supervised in write mode on a graph stored in the catalog.
CALL gds.graphSage.supervised.write(
  graphName: String,
  configuration: Map
)
YIELD
  computeMillis: Integer,
  nodePropertiesWritten: Integer,
  preProcessingMillis: Integer,
  writeMillis: Integer,
  configuration: Map
Table 10. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 11. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE supervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

predictedProbabilityProperty

String

n/a

yes

The node property in which the class probability list is stored. If omitted, the probability list is discarded.

writeConcurrency

String

'concurrency'

yes

The number of concurrent threads used for writing the node properties.

writeProperty

String

n/a

no

The node property in the Neo4j database to which the prediction is written

Table 12. Results
Name Type Description

computeMillis

Integer

Milliseconds for running the algorithm.

nodePropertiesWritten

Integer

Number of properties added to the projected graph.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

writeMillis

Integer

Milliseconds for writing result data back.

configuration

Map

The configuration used for running the algorithm.