[PYTHON] neo4j sandbox part 12

Overview

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

I recommend movies with jaccard.

MATCH (m:Movie {title:"Short Circuit (1986)"})-[:GENRE]->(g:Genre)<-[:GENRE]-(other:Movie)
WITH m,
	other,
	COUNT(g) AS intersection,
	COLLECT(g.name) AS i
MATCH (m)-[:GENRE]->(mg:Genre)
WITH m,
	other,
	intersection,
	i,
	COLLECT(mg.name) AS s1
MATCH (other)-[:GENRE]->(og:Genre)
WITH m,
	other,
	intersection,
	i,
	s1,
	COLLECT(og.name) AS s2
WITH m,
	other,
	intersection,
	s1,
	s2
WITH m,
	other,
	intersection,
	s1 + filter(x IN s2 WHERE NOT x IN s1) AS union,
	s1,
	s2
RETURN m.title,
	other.title,
	s1,
	s2,
	((1.0 * intersection) / SIZE(union)) AS jaccard
ORDER BY jaccard DESC
LIMIT 5

python execution result

title   jaccard
Cocoon: The Return (1988)  1.0
Evolution (2001)  1.0
Hot Tub Time Machine (2010)  1.0
Cocoon (1985)  1.0
Americathon (1979)  1.0

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
datetime part 1
numpy part 1
argparse part 1
numpy part 2