GraphSAGE supervised (AGA-only)Preview
|
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. |
CALL gds.graphSage.supervised.train(
graphName: String,
configuration: Map
)
YIELD
preProcessingMillis: Integer,
trainMillis: Integer,
configuration: Map
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
activationFunction |
String |
|
yes |
The activation function to use. Valid values are "relu" and "sigmoid" |
aggregator |
String |
|
yes |
The neighborhood embedding aggregator to use. Valid values are "mean" and "max" |
batchSize |
Integer |
|
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 |
|
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 |
|
yes |
The dropout probability for each layer. Must be a value >= 0.0 and < 1.0 |
embeddingDimension |
Integer |
|
yes |
The node embedding dimension of the model layers' outputs |
epochs |
Integer |
|
no |
The number of epochs to train the model |
epochsPerVal |
Integer |
|
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 |
|
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 |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
layerNormalization |
Boolean |
|
yes |
Whether to apply layer normalization between the model layers |
learningRate |
Float |
|
yes |
The learning rate for the optimizer |
modelName |
String |
|
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 |
|
yes |
The number of neighbors to sample for each layer. Note that this also determines the number of layers |
randomSeed |
String |
|
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 |
|
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 |
|
no |
The node label (i.e. type) to train to predict on |
targetProperty |
String |
|
no |
The node property to train to predict, represented by a column in the input node table of the specified 'target_label'. |
| 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. |
CALL gds.graphSage.supervised.stream(
graphName: String,
configuration: Map
)
YIELD
nodeId: Integer,
predictedClass: Integer,
predictedProbabilities: List
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
batchSize |
Integer |
|
yes |
The number of nodes per batch. |
featureProperties |
List of String |
|
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 |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
modelName |
String |
|
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 |
|
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. |
| 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. |
CALL gds.graphSage.supervised.mutate(
graphName: String,
configuration: Map
)
YIELD
computeMillis: Integer,
mutateMillis: Integer,
nodePropertiesWritten: Integer,
preProcessingMillis: Integer,
configuration: Map
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
batchSize |
Integer |
|
yes |
The number of nodes per batch. |
featureProperties |
List of String |
|
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 |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
modelName |
String |
|
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 |
|
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 |
|
no |
The node property in the GDS graph to which the embedding is written. |
predictedProbabilityProperty |
String |
|
yes |
The node property in which the class probability list is stored. If omitted, the probability list is discarded. |
| 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. |
CALL gds.graphSage.supervised.write(
graphName: String,
configuration: Map
)
YIELD
computeMillis: Integer,
nodePropertiesWritten: Integer,
preProcessingMillis: Integer,
writeMillis: Integer,
configuration: Map
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
graphName |
String |
|
no |
The name of a graph stored in the catalog. |
configuration |
Map |
|
yes |
Configuration for algorithm-specifics and/or graph filtering. |
| Name | Type | Default | Optional | Description |
|---|---|---|---|---|
batchSize |
Integer |
|
yes |
The number of nodes per batch. |
featureProperties |
List of String |
|
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 |
|
yes |
An ID that can be provided to more easily track the algorithm’s progress. |
modelName |
String |
|
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 |
|
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 |
|
yes |
The node property in which the class probability list is stored. If omitted, the probability list is discarded. |
writeConcurrency |
String |
|
yes |
The number of concurrent threads used for writing the node properties. |
writeProperty |
String |
|
no |
The node property in the Neo4j database to which the prediction is written |
| 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. |