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 2 of 22
The real wordsTheory

The ratings matrix, and its holes

User-item matrixA table with one row per user and one column per item, holding the ratings that exist. Most cells are empty, and the empty cells are the whole problem.

The class workbook has 5 users x 6 films = 30 cells, and 7 are blank. Section B's assignment has 30 cells with 8 marked with a question mark.

A recommender is a machine for filling in one blank cell. Once every blank is filled, recommending is just sorting each user's predicted ratings and showing the top few.