Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-14-2020 07:30 PM
I tried PageRank on this guide:
https://guides.neo4j.com/4.0-intro-graph-algos-exercises/PracticalApplication.html
I listed the score of PG for the largest group of Ingredient node then I only got the same score about 0.15 for all nodes:
CALL gds.pageRank.stream({
nodeQuery:'MATCH (i:Ingredient) WHERE i.ingredient_community = 377
RETURN id(i) as id',
relationshipQuery:'MATCH (s:Ingredient)-[r:COMMONLY_USED_TOGETHER]->(t:Ingredient)
WHERE s.ingredient_community = 377 AND t.ingredient_community = 377
RETURN id(s) as source, id(t) as target,r.score as weight',
relationshipWeightProperty:'weight'})
YIELD nodeId,score
return nodeId, score
ORDER BY score DESC
How can I get more useful PG scores from this graph?
Solved! Go to Solution.
12-15-2020 07:53 AM
I have checked the dataset and found the error:
It seems that the query in part 3 should be fixed to:
CALL gds.graph.writeRelationship('ingredient', 'COMMONLY_USED_TOGETHER', 'score')
In the current setup, all relationship weights are null, because we don't export relationship properties from mutated relationships. Seems like when the relationship weights are null, PageRank algorithm dismisses the relationships as non-existent. I will report this to the GDS team. With the current setup, you would have to ignore relationship weights and it would work as well.
CALL gds.pageRank.stream({
nodeQuery:'MATCH (i:Ingredient) WHERE i.ingredient_community = 377
RETURN id(i) as id',
relationshipQuery:'MATCH (s:Ingredient)-[r:COMMONLY_USED_TOGETHER]->(t:Ingredient)
WHERE s.ingredient_community = 377 AND t.ingredient_community = 377
RETURN id(s) as source, id(t) as target,r.score as weight'})
YIELD nodeId,score
return nodeId, score
ORDER BY score DESC
Thanks for letting us know!
12-15-2020 06:23 AM
Hey gigauser,
When you get the same score of 0.15 for all nodes, that means that no relationships have been projected. The PageRank value of 0.15 is the default value for nodes with no incoming relationships.
Do you get any result when you run the following query:
MATCH p=(s:Ingredient)-[r:COMMONLY_USED_TOGETHER]->(t:Ingredient)
RETURN p LIMIT 10
If not, you should repeat Part 1, Part 3, and Part 5 of the guide.
12-15-2020 07:05 AM
Hi Bratanic,
Thank you for the help. Yes I got the relationships. I wonder whether it is correct to have the relationships both directions.
12-15-2020 07:16 AM
You can test by loading the dataset. This guide looks no problem outwardly.
I can get all result as it described. But when I looked the inside of the result by listing PG scores, I found some wrong in my graph or in this guide.
CREATE CONSTRAINT ON (r:Recipe) ASSERT r.name IS UNIQUE
CREATE CONSTRAINT ON (i:Ingredient) ASSERT i.name IS UNIQUE
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "https://github.com/neo4j-apps/neuler/raw/master/sample-data/recipes/recipes.csv" AS row
MERGE (r:Recipe{name:row.recipe})
WITH r,row.ingredients as ingredients
UNWIND split(ingredients,',') as ingredient
MERGE (i:Ingredient{name:ingredient})
MERGE (r)-[:CONTAINS_INGREDIENT]->(i)
12-15-2020 07:53 AM
I have checked the dataset and found the error:
It seems that the query in part 3 should be fixed to:
CALL gds.graph.writeRelationship('ingredient', 'COMMONLY_USED_TOGETHER', 'score')
In the current setup, all relationship weights are null, because we don't export relationship properties from mutated relationships. Seems like when the relationship weights are null, PageRank algorithm dismisses the relationships as non-existent. I will report this to the GDS team. With the current setup, you would have to ignore relationship weights and it would work as well.
CALL gds.pageRank.stream({
nodeQuery:'MATCH (i:Ingredient) WHERE i.ingredient_community = 377
RETURN id(i) as id',
relationshipQuery:'MATCH (s:Ingredient)-[r:COMMONLY_USED_TOGETHER]->(t:Ingredient)
WHERE s.ingredient_community = 377 AND t.ingredient_community = 377
RETURN id(s) as source, id(t) as target,r.score as weight'})
YIELD nodeId,score
return nodeId, score
ORDER BY score DESC
Thanks for letting us know!
12-15-2020 08:12 AM
What a nice of you! Now I can get the different PG scores from the graph.
Thank you for helping me teach my customers better with this guide.
Dongho.
03-01-2022 04:40 AM
Hi @bratanic.tomaz , did you get a chance to have it fixed? As right now I am running a fraud detection graph without weights in the relations and the pagerank scores are still all 0.15. I checked and the connection between nodes are there so wonder if it has something to do with the bug you mentioned?
03-01-2022 04:57 AM
I believe it's the same, if relationship weights are missing, then the relationship is dismissed. However, you can always use a default relationship weight property using either native or cypher projection.
All the sessions of the conference are now available online