How does graph-based recommendation work
by Alexandra Klacanova
· 4 min read
Not so long ago, our very own Luanne gave an amazing talk titled Maltaware: Discovering what to drink with Neo4j on Nodes2020. Luanne demonstrated the value of graphs, and why they are the perfect fit for recommendation engines with an example of a whisky recommendation engine. Let me quickly walk you through a summary of why graphs and recommendation engines go together so well.
Recommendation engines are everywhere - they are used to suggest products you may like, people you may know, places you could enjoy traveling to, and more. Recommendation engines provide immense value to businesses as they improve user experience and drive retention.
Let’s look at how you can use Hume and the leader in graph databases, Neo4j, in order to make the best, most accurate recommendations quickly and even solve the cold start problem.
Recommendations are based on what we know either about the users - User-based recommendations - which suggest items that users similar to us like, or items - Item based recommendations - that nudge us to try items similar to items we already like. Whether you want to produce a user- or an item-based recommendation, what is essential is the data about the user or the item. Let’s look at the example of whiskies Luanne used on Nodes2020. If two people each like five whiskies and three out of these are the same, we could recommend both of these people to try the remaining two whiskies the other person likes - this would be a user-based recommendation. An item-based recommendation on the other hand, would look at the characteristics of a whisky one likes and search the database for another whisky with similar attributes (richness, smokiness, flavors) - this is shown on the picture below.
The same would work with anything else - if you have travelled to the same places as someone else (let’s say Varna and Mallorca) and they have also travelled to Antalya, it’s valid to assume you’d be interested in going there as well (user-based recommendation). Or, if you bought plates in a specific style in Ikea, you might be recommended to buy matching coffee cups based on matching product characteristics - even though cups are a different product category than plates, the recommendation engine would deem the items similar based on their matching style. This would be an item-based recommendation.
But what if we do not have the essential data about users or items? In other words - back to our whisky example - which whisky do we recommend to people we have very little information about? One potential solution to this cold start problem is to recommend a generally well-liked whisky - thus leveraging the data we have about other users and whiskies. Naturally, this works with all other kinds of products, for example, holiday destinations or movies.
If we do have a little bit of data about a user, we can make a content-based recommendation. In our whisky example, a content-based recommendation would use the characteristics of the whisky a user liked to find a whisky that shares some of the characteristics - flavors, level of smokiness, richness, etc. - and recommend him/her to try that one. This would work the same with different products - the recommendation engine would take the product characteristics of the product(s) already purchased by a user to find products with similar features to recommend - e.g., beach resorts, hotels, or movies with a certain actor.
So let’s sum it up, why are graphs, Neo4j, and Hume the right solution for recommendation engines?
- Graphs see value in relationships - As graph databases assign equal importance to data, and the relationships among the data, it’s intuitive to use them to provide recommendations.
- Explainable - Graph visualizations make it easier than black box statistical approaches to understand why certain recommendations were given. Being able to explain this translates to easy updating of the algorithm if the recommendations are not accurate enough.
- Adaptable - Neo4j is schema free, and thus it is easy to add or adapt nodes, relationships, and properties into a dataset. This allows for more accurate and informed recommendations.
- High-Performing - Neo4j allows real-time traverses across the graph database, which means the recommendations are given quickly and thus, are accurate in terms of being up to date.
- And more - Go watch Luanne’s talk to further explore similarity algorithms, node embeddings and personalization queries in the context of whisky recommendations!
No matter the use case, if you are building a recommendation engine, you need a performant database. You also need to be able to pull data from your database quickly, as well as analyze the data in real-time - all of this is possible thanks to graphs and Neo4j. At GraphAware we have years of experience with recommendation engines, in fact, our Chief Scientist built the very first recommendation engine based on a graph. After many years of building them for customers, we leveraged our knowledge to build Hume - the perfect application to host a graph based recommendation engine. Hume makes it easy to explain the recommendations made and verify the algorithms employed. If you are building a recommendation engine let us know and take Hume for a spin.
In short: (Recommender Systems)-[:LOVE]->(Graphs)