Date Night: Never Disagree on a New Movie Again (with Neo4j) [Community Post]

Learn about Date Night: A Movie Recommendation Engine Powered by Neo4j

[As community content, this post reflects the views and opinions of the particular author and does not necessarily reflect the official stance of Neo4j.]

Have you ever spent so much time trying to decide what movie to watch that you don’t end up watching anything at all?

You and your significant other sit down on the couch and the negotiations begin immediately. You open with a sequel to a movie you both liked, but your partner counters that it got horrible reviews before proposing a long movie you know you won’t be able to stay awake for.

At this point, the scrolling begins as you pass countless titles that aren’t going to work. Nope. Nah. Meh. No way.

We all know the secret to any good relationship is compromise, so why is it so hard when it comes to picking a movie on Friday night?

Introducing Date Night: The Movie Suggestion App

It turns out people have pretty complex taste in movies. Two friends might like the same film, but for different reasons. One person might love an actor but loathe a certain genre, so combining the two doesn’t necessarily equal success (or failure).

At MediaHound, a few of our team members experienced this movie-picking fail first hand with their spouses and wanted to use our platform – The Entertainment Graph® – to solve this all-too-common problem.

That solution is Date Night: An app that takes one movie suggestion from you and one from somebody else then uses our data to provide a list of recommendations you’ll both enjoy.

We added handy availability filters so people can narrow the recommendations down to their favorite service or store, as well as trailers to aide in the decision-making process. You can try Date Night on the web, Apple TV or iPad.

The Platform Behind the Magic: The Entertainment Graph

We had entertainment discovery products like Date Night in mind when we built The Entertainment Graph using Neo4j.

The Entertainment Graph connects all music, books, games, movies and TV through the contributors, genres and traits that give this content meaning and context. The relationships in our data allow us to deliver incredible personalization to users, and these data relationships are perfect for helping two people meet in the middle when they want to watch something together.

For those who aren’t familiar, Neo4j is the world’s leading native graph database, and it’s ideal for making recommendation engines because it stores data as nodes connected by relationships, not rows referenced in tables. Neo4j is super powerful when it comes to analyzing multiple traits or factors. Read more here about building recommendation engines with Neo4j.

Using Cypher to Build Date Night

The first Date Night recommendation engine was developed and demoed using Cypher, Neo4j’s powerful native graph query language. Cypher’s pattern-matching abilities allow us to perform millions of graph traversals instantly to arrive at the most highly shared traits between two movies.

In just a few hours, we were able to develop a working prototype that returned results good enough to celebrate. Here is that first Cypher recommendation query:

MATCH (m:Movie)
WHERE IN ["The Notebook", "Gladiator"]
WITH collect(m) AS mSet
WITH mSet, length(mSet) AS mSize
WITH mSize, mSet UNWIND mSet AS m
MATCH (m)-[:TRAIT]->(t:Trait)
WITH mSet, mSize, t, length(collect(m)) AS moviesByTraitSize, collect( AS moviesByTraitName
MATCH (t)<-[:TRAIT]-(nSet) WHERE NOT nSet IN mSet
WITH mSize, nSet, collect(DISTINCT {trait: t, weight: moviesByTraitSize}) 
     AS traits, collect(DISTINCT 
     AS sharedTraits, collect(DISTINCT moviesByTraitName) AS moviesByTraitName
WITH mSize, nSet, traits, sharedTraits, length(sharedTraits) 
     AS sharedTraitsSize, reduce(s = 0, t IN traits | s + t.weight + (t.weight / mSize) * t.weight) 
     AS traitWeight, moviesByTraitName
WITH mSize, nSet, traits, sharedTraits, sharedTraitsSize, traitWeight, moviesByTraitName, length(sharedTraits) + traitWeight 
     AS score ORDER BY score DESC, nSet.mhid
RETURN AS name, score, traitWeight, sharedTraitsSize, sharedTraits LIMIT 6;

The first challenge for any recommendation engine is to define the type and number of inputs it should receive.

MediaHound’s recommendation engine is differentiated by its ability to accept a great variety of inputs, which we call the mSet. The mSet may consist of users, collections, movies, TV series, albums, books, games and nearly any other type of entertainment media. The Entertainment Graph contains millions of nodes that could comprise this mSet.

Our recommendation engine traverses from the starting mSet out to all first-level traits called the tSet. Traits are the features inherent to the content node they are connected to, they describe the content and put it in context. For example, a movie node might be connected to a genre trait called Action and a mood called Exciting. This descriptive tSet is analyzed to determine which traits are shared the most across the mSet.

The recommendation engine then traverses through a distinct tSet to all connected nodes throughout The Entertainment Graph, called the nSet. The nSet scoring algorithm is based on the relative connectedness of the nSet to the starting mSet (two movies in the case of Date Night). From there, the engine accepts many filter features called the fSet (not present in the initial Cypher), which can include source availability, appropriateness ratings, media types, content formats and even required connections to other nodes.

These filters can also consider whether something belongs to a collection or is connected to particular users, like your friends or influencers. The fSet filters are applied on the ordered nSet content to produce the final result set called rSet, which will be presented to the user. Paging is applied to the rSet and returned in real time to deliver a seamless, personalized entertainment discovery experience for two people – the product we call Date Night.

Now It’s Your Turn: Experience Date Night and The Entertainment Graph

The Date Night apps have served over one million recommendation sets so far and we’ve received some great user feedback along the way. This week, we will demo Date Night at Digital Entertainment World as an example of what The Entertainment Graph and Neo4j are capable of.

Our API program is currently in private beta, so if you want to build your own app on top of this unique platform please feel free to sign up here.

Download this whitepaper – Powering Recommendations with a Graph Database – and discover how companies like eBay, Walmart and Glassdoor are using graph databases to power their recommendation engines.