Issue incorporating centrality features in gds node classification model

Hi, I am new to Neo4j. I am trying to build a node classification model with binary classes. I created new features using Centrality Algorithms (such as Eigenvector & Betweensess Centrality). I have used the 'Write' Syntax to add the centrality output values back as node properties to my projected graph

However, when I proceed to add this Node Property by scaling it and proceed to training step, I hit into errors saying not all my nodes have this node property.

  • Add Node Property Step
    </> CALL gds.beta.pipeline.nodeClassification.addNodeProperty('pipe-with-context1', 'scaleProperties', {
    nodeProperties: 'eigenvector_centrality',
    scaler: 'Mean',
    mutateProperty:'scaledEigen',
    contextNodeLabels: ['keys']
    })
    YIELD name, nodePropertySteps </>

  • Select Feature Step
    </> CALL gds.beta.pipeline.nodeClassification.selectFeatures('pipe-with-context2', ['scaledEigen'])
    YIELD name, featureProperties </>

  • Training Step
    </> CALL gds.beta.pipeline.nodeClassification.train('myGraph', {
    pipeline: 'pipe-with-context2',
    targetNodeLabels: ['labelled_values'],
    modelName: 'nc-pipeline-model-contextual',
    targetProperty: 'class',
    randomSeed: 1337,
    metrics: ['ACCURACY']
    }) YIELD modelInfo, modelSelectionStats
    RETURN
    modelInfo.bestParameters AS winningModel,
    modelInfo.metrics.ACCURACY.train.avg AS avgTrainScore,
    modelInfo.metrics.ACCURACY.outerTrain AS outerTrainScore,
    modelInfo.metrics.ACCURACY.test AS testScore,
    [cand IN modelSelectionStats.modelCandidates | cand.metrics.ACCURACY.validation.avg] AS validationScores </>

This is the snippet of error message I got:


I have checked, all the nodes seem to have these centrality properties.

Appreciate guidance/help on this. Thank you.

Hello @yitheng.sea ,
When you talk about write sytnax, you are referring to gds.eigenvector.write?
This procedure will not write the property to the projected graph, but the persisted graph in the db.
If you want to update the projected graph, you should use gds.eigenvector.mutate.

If thats not working, could you run gds.graph.list('myGraph') and show me the schema?

Hi @florentin_dorre , thanks for the reply and tips! I ran gds.graph.list('myGraph') and realized the issue was I overlooked and forgot to add the node properties to my requested label node when I project the graph.

Thank you once again!

1 Like