[MUSIC] So this notion of collaborative filtering is that somehow we wanna leverage what other people have purchased. And the case of product recommendation or other links more generically between users and items, to make recommendations for other users. And so it seems very intuitive that when we're thinking about doing product recommendation that we wanna build in information like if a person bought this item, then they're probably also interested in some other item because we've seen lots and lots of examples in the past of people buying those pairs of items together. Maybe not simultaneously, at the same time, but in the course of their purchase histories. Okay, so this brings us to the idea of co-occurrence of purchases. So, for example, if I was just on Amazon, buying diapers, well, we've probably seen lots of examples of people who bought diapers also bought baby wipes. Okay, so how can we use this type of co-occurrence of purchases to make recommendations? [SOUND] Okay [LAUGH] so let's talk about this co-occurrence matrix that we're gonna build up. And this is gonna store all of our information about which purchases people bought together. And again, when I say together I don't mean simultaneously, just together at some point in their history of purchases. So I'm gonna build up this Matrix C and this matrix is an items by items matrix. Okay, so we're gonna list all the different items for our rows of this matrix. And likewise, all the different items, for the columns. So, for example, maybe this row of this matrix, might be the row corresponding to diapers. And then if this is lets say the third row of this matrix, then I would also have that the third column of this matrix Corresponds to diapers as well. Okay, and so if I want to say that many people purchased diapers and baby wipes, let's look at the row for diapers and then we scroll over to the column for, let's say this column here, is for baby wipes. And in this entry, of this matrix there's some number entered. And that number represents the number of people. Purchasing both diapers and baby wipes. Okay, well, let me ask you a question. Is the number of people who purchased diapers and baby wipes the same as the number of people who purchased baby wipes and diapers? Yes, so we would go to the baby wipes row. And this diapers column and notice that this is the exactly same number, okay? And so what this means is this a symmetric matrix that, if we look across the diagonal here, Then we're gonna see a reflection. If we took this matrix and folded it across that little diagonal line I just drew you would get exactly the same numbers matching up. Okay, and just to reiterate the way we're gonna build up this co-occurrence matrix, is we're gonna search through all the user's history of purchases they've made, and count. And every time we see a purchase of diapers we'll add of diapers along with all the other items, we're gonna add one to that entry, and we're gonna keep incrementing that matrix as we're searching over users. Okay, but now let's talk about how we're gonna use this co-occurrence matrix in order to make recommendations. And it's really, really straight forward. So let's say that a user has just purchased diapers, and I wanna make some recommendation for them. Well what I'm gonna do is I'm gonna look at the diapers row of this matrix, so if we go back, to that, C matrix here, I'm gonna grab out this diapers row, and I'm just gonna draw that row here. And what this row has is how often people bought diapers and, remember, baby wipes was one of the items. Oops, sorry, not baby items, baby wipes. And that has, let's say a 100 counts. And then there's also let's say pacifiers. And maybe there are 4 counts of pacifiers. Let's think of something else. So let's say that there's some DVD, let's say there's no counts of those DVDs. We're gonna have this whole vector of counts of how many times people who bought diapers, bought all these other products. Using this, now we can very straightforwardly make our recommendations. All we do is we sort this vector and recommend the items with the largest counts. So maybe, we'll recommend baby wipes, and milk, and baby food, and things like this for somebody who just purchased diapers. [MUSIC]