cancel
Showing results for 
Search instead for 
Did you mean: 

Graph Data Science: Filtered Node Similarity

stu_v_kerr
Node Clone

Is there a Filtered Node Similarity Example example that i can reference? I am having difficulty configuring node filters for a bipartite projection. From what i can find, Neo4j current documentation does not include an example and truncates some of the syntax for TargetNodeFilters and SourceNodeFilters. For one of my labels, I have projected a numerical vector that resulted from one-hot encoding. For this label, i want to filter the nodes as input to the similarity algorithm using a node filter on that numerical vector. For example:

MATCH (p:Person) where p.vector[0] = 1 AS people
sourceNodeFilter: people

In the node similarity call, where do the above cypher "fit" in the call? Here is what is currently not working...

gds.run_cypher('''
CALL gds.nodeSimilarity.stream('playsSong',

{ degreeCutoff: 30,
relationshipWeightProperty: 'count',
'MATCH (p:Person) WHERE p.vector[0] = 1 as people',
sourceNodeFilter: 'people'
}
)
YIELD node1, node2, similarity

2 REPLIES 2

stu_v_kerr
Node Clone

I have changed the similarity call
from: CALL gds.nodeSimilarity.stream()
to: CALL gds.alpha.nodeSimilarity.filtered.stream()
and still not sure if call is working correctly

Additonal question about how to use "sourceNodeFilter"

    Relating this topic, I am struggling with the appropriate use of Cypher relating to Filtered Node Similarity Algo.
    I would appreciate if someone would teach me how to use “sourceNodeFilter” (or “targetNodeFileter” ) of Filtered Node Similarity algo.

      I want to use the following option for “sourceNodeFilter” (or “targetNodeFilter”)
-------------------------

a list of nodes

MATCH (person:Person) WHERE person.age > 35 collect(person) AS people … sourceNodeFilter: people

-------------------------
        However I do not understand how I should exactly write the above in the query sentence. Could someone give me an example?
        My query which is not working is like this:

-------------------------
CALL gds.alpha.nodeSimilarity.filtered.stream('myGraph',
{ MATCH (person:Person) WHERE person.age = 35 collect(person) AS people, sourceNodeFilter:people,
topN:3
})

YIELD node1, node2, similarity

-------------------------

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.