Skip to content
BI & Data ScienceRecommender systems and collaborative filtering

Formulas for this chapter

Content-based prediction

P(u,i) = average of u's ratings on items sharing i's attribute

When the item has attributes and the user has some history. Works from the first rating, and on items nobody has rated yet.

u
The target user
i
The item whose rating is missing
attribute
In the assignment, the Type column: Sci-Fi or Action

Pearson similarity between users

sim(u,v) = CORREL(ratings of u, ratings of v) computed over the items both rated only

Step one of user-based collaborative filtering, once per other user. Anchor the target user's range with dollar signs so the formula fills down.

sim(u,v)
Correlation from -1 to +1; +1 identical taste, -1 opposite
shared items
Columns where both users have a numeric rating; CORREL selects them automatically

User-based collaborative filtering prediction

P(u,i) = rubar + [ sum over v in N of sim(u,v) x (r(v,i) - rvbar) ] / [ sum over v in N of |sim(u,v)| ] class layout: Ans = (Sum of Correl x Difference) / (Sum of |Correl|) + Average(u)

Filling one blank cell of the ratings matrix. Clip the answer to the rating range: the formula is unbounded.

rubar
The target user's own average rating, the baseline
N
Neighbourhood: only the users who themselves rated item i
r(v,i) - rvbar
Neighbour v's mean-centred rating of i, the Difference column
|sim(u,v)|
Absolute similarity, so positive and negative neighbours cannot cancel in the denominator

Item-based collaborative filtering prediction

P(u,i) = sum over j of sim(i,j) x r(u,j) / sum over j of |sim(i,j)|

The same arithmetic with the matrix transposed. Preferred at scale, because items are fewer than users and item-item similarities can be precomputed.

sim(i,j)
Similarity between items i and j, from how users rated them
r(u,j)
This user's own rating of the similar item j
Step 1 of 22
The ideaTheory

Two ways to guess what you will like

A friend recommends a film. There are only two things she can be going on.

Either she knows what you already liked and picks something similar to it. Or she knows someone whose taste matches yours, and picks what they liked.

The first is content-based filtering. The second is collaborative filtering. Section B's group assignment asks for both on the same six films, which is the clearest way to see that they are genuinely different machines.