[PYTHON] neo4j sandbox part 11

Overview

I tried sandbox with neo4j. movielens, I tried it. I made a recommendation.

We recommend movies of the genre that users are evaluating.

MATCH (u:User {id:21})-[r:RATING]->(m:Movie)
WITH u,
	avg(r.rating) AS mean
MATCH (u)-[r:RATING]->(m:Movie)-[:GENRE]->(g:Genre)
WHERE r.rating > mean
WITH u,
	g,
	COUNT(*) AS score
MATCH (g)<-[:GENRE]-(rec:Movie)
WHERE NOT EXISTS((u)-[:RATING]->(rec))
RETURN rec.title AS recommendation,
	COLLECT(DISTINCT g.name) AS genres,
	SUM(score) AS sscore
ORDER BY sscore DESC
LIMIT 5

python execution result

title   genres  score
Confessions of a Dangerous Mind (2002)   ['COMEDY', 'CRIME', 'THRILLER', 'DRAMA', 'ROMANCE']  639
Maximum Ride (2016)   ['SCI-FI', 'COMEDY', 'ACTION', 'THRILLER', 'ADVENTURE', 'FANTASY']  637
Rubber (2010)   ['COMEDY', 'ACTION', 'CRIME', 'THRILLER', 'DRAMA', 'MYSTERY', 'ADVENTURE', 'WESTERN', 'HORROR', 'FILM-NOIR']  632
Mars Needs Moms (2011)   ['SCI-FI', 'COMEDY', 'ACTION', 'ADVENTURE', 'CHILDREN', 'ANIMATION', 'IMAX']  628
Dragonheart 2: A New Beginning (2000)   ['COMEDY', 'ACTION', 'THRILLER', 'DRAMA', 'ADVENTURE', 'FANTASY']  606


that's all.

Recommended Posts

neo4j sandbox part 12
neo4j sandbox part 5
neo4j sandbox part 13
neo4j sandbox part 15
neo4j sandbox part 16
neo4j sandbox part 11
sandbox with neo4j part 10
numpy part 1
argparse part 1
numpy part 2