MATCH (p:Person), (c:Cuisine)
OPTIONAL MATCH (p)-[likes:LIKES]->(c)
WITH {item:id(p), weights: collect(coalesce(likes.score, 0))} as userData
WITH collect(userData) as data
CALL algo.similarity.pearson.stream(data)
YIELD item1, item2, count1, count2, similarity
RETURN algo.getNodeById(item1).name AS from, algo.getNodeById(item2).name AS to, similarity
ORDER BY similarity DESC
Returns results:
from
to
similarity
"Zhen"
"Arya"
95.31377377744579
"Michael"
"Arya"
68.20606579452823
"Arya"
"Karin"
64.31334147339001
"Zhen"
"Michael"
55.139295305548224
"Praveena"
"Karin"
51.19999999999999
"Zhen"
"Karin"
49.35545314063058
"Praveena"
"Arya"
42.800450683143545
"Michael"
"Karin"
27.800000000000008
"Praveena"
"Michael"
4.199999999999998
"Zhen"
"Praveena"
2.699126343628236
Results for Zhen and Arya should be -0.9235830792388159
When running
algo.similarity.pearson.stream
I get similarity returned that is out of -1 to 1 range. Running on Neo4j 3.5Create sample graph:
Run the algorithm:
Returns results:
Results for Zhen and Arya should be -0.9235830792388159
as calculated from
RETURN algo.similarity.pearson([10, 0, 6, 0, 0],[0, 10, 0, 10, 7])