Add existing node properties to link prediction pipeline in neo4j?

Viewed 36

How do I add existing Node properties of a node in the graph projection to the ML pipeline?

As far as I know, the gds.beta.pipeline.linkPrediction.addNodeProperty procedure takes different other procedures to creates node embeddings as new node properties to the pipeline but how do I add existing ones? Getting the below error even though the properties are projected in the memory graph.

Failed to invoke procedure gds.beta.pipeline.linkPrediction.train: Caused by: java.lang.IllegalArgumentException: Node properties [property1, property2, property3] defined in the feature steps do not exist in the graph or part of the pipeline

1 Answers

You can add an existing node property to the link prediction pipeline by adding it to your graph projection ->

CALL gds.graph.project('test', 'Node', 'Relationship', {nodeProperties: ['property'1]})

Then you can use it the link prediction pipeline by defining the link feature:

CALL gds.beta.pipeline.linkPrediction.addFeature('pipe', 'hadamard', {
  nodeProperties: ['property1']
}) YIELD featureSteps

You can have multiple link features. The addProperty method is only used when you want to execute a graph algorithm to calculate the new property, like in the example with the fastRP embeddings.

CALL gds.beta.pipeline.linkPrediction.addNodeProperty('pipe', 'fastRP', {
  mutateProperty: 'embedding',
  embeddingDimension: 256,
  randomSeed: 42
})

If the node property is already present in the projected graph, you can skip the add node property step.

Related