0
0

More than 3 years have passed since last update.

neo4jでsandbox その12

Last updated at Posted at 2020-10-08

概要

neo4jでsandboxやってみた。
movielens、やってみた。
レコメンドしてみた。

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実行結果

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

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0