Check out a free preview of the full Complete Intro to Databases course
The "Recommendation Algorithm Example" Lesson is part of the full, Complete Intro to Databases course featured in this preview video. Here's what you'd learn in this lesson:
Brian demonstrates how to use another algorithm in an Neo4j database, the recommendation algorithm, which allows engineers to generate movie recommendations by finding which actors partnered the most with a given actor, and recommending their movies.
Transcript from the "Recommendation Algorithm Example" Lesson
[00:00:00]
>> Let's say you're making a movie recommendation site. Not that I would know anything help working at large streaming movie sites. And let's say our recommendation algorithm that we want to try today is we want to say I was like alright, this person has seen, 45 films by Halle Berry.
[00:00:21]
They probably really like Halle Berry or Kristen Stewart, for example, but today we're gonna be using Halle Berry. We wanna query our network for things that Halle Berry has acted in. And then we want to jump to like recommendations have people that have been in films with Halle Berry so that they can go check out other films.
[00:00:45]
So the way that we could do that is we can come in and say, match. Halle as a person, right and then acted in. And we wanna jump, but we don't wanna jump too far, right? So as you may imagine, I don't wanna jump to this person has been in this too far of a network effect, we wanna just jump to immediately, has been in the same film with Halle Berry.
[00:01:18]
So we can do acted in Star and then we do one dot dot four. And that's going to put an upper cap of how far this will explore our graph. Okay, and then I'm not going to add a directionality because they're going to have both, directions in both directions.
[00:01:37]
I wanna say this is gonna be our recommendation the person that we wanna recommend to our movie viewer that really likes Halle Berry. Okay, and then we'll say where. Halle dot name equals, Halle Berry [SOUND] RETURN DISTINCT [SOUND] Recommendation [SOUND] Dot name And then we also want to put an order by right because if someone continually shows up in a lot of films with Halle Berry, that would be a good indication that we'd want to recommend someone, this particular actor or actress.
[00:02:26]
So when I say order by. Recommendation.name. We could also put count star here, and say. Count star comma recommendation dot name. All right. So now we should be able to run this query. And we'll get back. In this particular case, no one's been in here we go. Probably should have done that descending.
[00:03:03]
Let's read that again. So now you can see Carry on mass Canneries and Laurence Fishburne and Meg Ryan have all been in three films with Halle Berry. So this is a good indication, we should recommend this film or these actors and actresses. To this person that really likes Halle Berry.
[00:03:23]
This is a terrible recommendation algorithm. But I think you can kind of see here, you can kind of explore graphs and see the interesting ways things are connected. Like this would be better for like bands for example, right? Like if you listen to this band a lot and your friend listens to the same band a lot and they also listen to this other than a ton than you don't right.
[00:03:46]
That would be a good recommendation, for you. So let's talk about the one, dot four here. This is kind of letting it know the upper bounds of how far you want to jump. If I put six here because I think this is it also includes you have to jump to a film and then to a person.
[00:04:07]
I think if I put six here you're gonna get a lot more people right for example, her very extended right so people that have acted in films. With Haile Berry that I've acted with someone else, right, that's the extended network. If you add an additional hop there, for whatever reason, Hugo Weaving is very much in her extended network.
[00:04:29]
And also for that matter, that's probably most of the graph at this point because that's a very wide graph if you if you allow for two hops
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops