1

The example on the online course calls for 3 Recommended actors that Keanu Reeves should work with but hasn't, the solution in that example is demonstrated as:

MATCH (keanu:Person {name:"Keanu Reeves"})-[:ACTED_IN]->()<-[:ACTED_IN]-(c),
      (c)-[:ACTED_IN]->()<-[:ACTED_IN]-(coc)
WHERE coc <> keanu  AND NOT((keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(coc))
RETURN coc.name, count(coc)
ORDER BY count(coc) DESC
LIMIT 3;

The results of the above

Tom Hanks   4
Stephen Rea 3
John Hurt   3

However, Tom Hanks played in 12 movies according to the sample database. Further more there's higher ranked movie stars like Meg Ryan that is not on that list.

My solution was this cypher

match (other:Person)-[:ACTED_IN]->(movie),
(keanu:Person {name:'Keanu Reeves'})
WHERE
NOT (keanu)-[:ACTED_IN]->(movie)
return other.name, count(movie)
order by count(movie) desc
limit 3;

Which results in the following:

Tom Hanks   12
Meg Ryan    5
Jack Nicholson  4

Am I missing something? Or is the example solution provided is not accurate.

I'm a total beginner to Neo4j so forgive me if I'm totally off my rocker.

4

2 回答 2

2

提供的解决方案称为协同过滤,即。喜欢我喜欢什么的人也喜欢什么。这种方法的基础是为自己找到一个“同行群体”。

您建议的是基于流行度或频率的指标。

现实世界的建议基于多个方面,具体取决于您的要求和用例。

有关介绍,请参阅此演示文稿:http: //de.slideshare.net/bachmanm/recommendations-with-neo4j-fosdem-2015

于 2015-02-01T10:24:29.047 回答
0

实际上,您没有正确理解任务(我第一次也是如此!)

问题的作者实际上问的是:找到三个与基努·里维斯一起出演过电影的演员,并且还没有与基努本人一起出演过任何电影。

而你解决了这个问题:找到三个尚未与基努·里维斯在同一部电影中出演过最多电影的演员

当然,对于问题作者的模棱两可的表述感到羞耻!

顺便说一句,我想向您展示我的替代解决方案,它看起来比作者提供的要短一些:

MATCH (actor:Person)-[:ACTED_IN]->()<-[:ACTED_IN]-(keanu:Person {name: "Keanu Reeves"}),
(other:Person)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(actor)
WHERE NOT (movie)<-[:ACTED_IN]-(keanu:Person {name: "Keanu Reeves"})
RETURN other.name, COUNT(*) as Movies
ORDER BY Movies DESC
LIMIT 3;
    ╒═══════════════╤════════╕
    │&quot;other.name"   │&quot;Movies"│
    ╞═══════════════╪════════╡
    │&quot;Tom Hanks"    │4       │
    ├───────────────┼────────┤
    │&quot;Jim Broadbent"│3       │
    ├───────────────┼────────┤
    │&quot;Halle Berry"  │3       │
    └───────────────┴────────┘
于 2021-02-08T20:37:04.377 回答