DR.
Nesma Ebrahim
Recommender Systems
Why recommendation?
The goal of recommender systems is…
• To help people discover new content
Why recommendation?
The goal of recommender systems is…
• To help us find the content we were
already looking for
Are these
recommendations
good or bad?
Why recommendation?
The goal of recommender systems is…
• To discover which things go together
Why recommendation?
The goal of recommender systems is…
• To personalize user experiences in
response to user feedback
Why recommendation?
The goal of recommender systems is…
• To recommend incredible products
that are relevant to our interests
Why recommendation?
The goal of recommender systems is…
• To identify things that we like
Why recommendation?
The goal of recommender systems is…
• To help people discover new content
• To help us find the content we were
already
To modellooking for
people’s
• To discover which things
preferences, go together
opinions,
• To personalize user experiences in
and behavior
response to user feedback
• To identify things that we like
Recommending things to people
Suppose we want to build a movie
recommender
e.g. which of these films will I rate highest?
Recommending things to people
We already have
a few tools in our
“supervised
learning” toolbox
that may help us
Recommending things to people
Movie features: genre, User features: age, gender,
actors, rating, length, etc. location, etc.
Recommending things to people
With the models we’ve seen so far, we
can build predictors that account for…
• Do women give higher ratings than men?
• Do Americans give higher ratings than Australians?
• Do people give higher ratings to action movies?
• Are ratings higher in the summer or winter?
• Do people give high ratings to movies with Vin Diesel?
So what can’t we do yet?
Recommending things to people
Consider the following linear predictor
(e.g. from week 1):
Recommending things to people
But this is essentially just two separate
predictors!
user predictor movie predictor
That is, we’re treating user and movie
features as though they’re independent
Recommending things to people
But these predictors should (obviously?)
not be independent
do I tend to give high ratings?
does the population tend to give high ratings to this genre of movie?
But what about a feature like “do I give
high ratings to this genre of movie”?
Recommending things to people
Recommender Systems go beyond the methods we’ve seen so
far by trying to model the relationships between people and
the items they’re evaluating
preference my (user’s) HP’s (item)
is the movie
Toward “preferences” “properties” action-
“action”
heavy?
Compatibility
preference toward
are the special effects good?
“special effects”
Today
Recommender Systems
2. Collaborative filtering
(performs recommendation in terms of user/user and item/item
similarity)
Defining similarity between users & items
Q: How can we measure the similarity
between two users?
A: In terms of the items they
purchased!
Q: How can we measure the similarity
between two items?
A: In terms of the users who purchased
them!
Defining similarity between users & items
e.g.:
Amazon
Definitions
Definitions
تم شراءه
= set of items purchased by user u
= set of users who purchased item i
Definitions
items
Or equivalently…
users
= binary representation items purchased by u
= binary representation of users who purchased i
0. Euclidean distance
Euclidean distance:
e.g. between two items i,j (similarly defined between two users)
A B
0. Euclidean distance
Euclidean distance:
e.g.: U_1 = {1,4,8,9,11,23,25,34}
U_2 = {1,4,6,8,9,11,23,25,34,35,38}
U_3 = {4}
U_4 = {5}
Problem: favors small sets, even if they
have few elements in common
1. Jaccard similarity
Maximum of 1 if the two
users purchased exactly the
same set of items
(or if two items were purchased by the
A B same set of users)
Minimum of 0 if the two users
purchased completely
disjoint sets of items
(or if the two items were purchased by
completely disjoint sets of users)
2. Cosine similarity
(theta = 0) A and B point in
exactly the same direction
(theta = 180) A and B point
(vector representation of in opposite directions (won’t
users who purchased
harry potter) actually happen for 0/1 vectors)
(theta = 90) A and B are
orthogonal
2. Cosine similarity
Why cosine?
• Unlike Jaccard, works for arbitrary vectors
• E.g. what if we have opinions in addition to purchases?
bought and liked
didn’t buy
bought and hated
2. Cosine similarity
E.g. our previous example, now with
“thumbs-up/thumbs-down” ratings
(theta = 0) Rated by the
same users, and they all agree
(theta = 180) Rated by the
(vector representation of same users, but they
users’ ratings of Harry
Potter) completely disagree about it
(theta = 90) Rated by
different sets of users
4. Pearson correlation
What if we have numerical ratings
(rather than just thumbs-up/down)?
bought and liked
didn’t buy
bought and hated
4. Pearson correlation
What if we have numerical ratings
(rather than just thumbs-up/down)?
• We wouldn’t want 1-star ratings to be parallel to 5-
star ratings
• So we can subtract the average – values are then
negative for below-average ratings and positive
for above-average ratings
items rated by both users average rating by user v
4. Pearson correlation
Compare to the cosine similarity:
Pearson similarity (between users):
items rated by both users average rating by user v
Cosine similarity (between users):
Collaborative filtering in practice
How did Amazon generate their ground-truth data?
Given a product: Let be the set of users
who viewed it
Rank products according to: (or cosine/pearson)
.86 .84 .82 .79 …
Collaborative filtering in practice
Note: (surprisingly) that we built
something pretty useful out of
nothing but rating data – we
didn’t look at any features of the
products whatsoever
Overview & recap
Tonight we’ve followed the
programme below:
1. Measuring similarity between users/items for
binary prediction (e.g. Jaccard similarity)
2. Measuring similarity between users/items for real-
valued prediction (e.g. cosine/Pearson similarity)
Summary
Recap
1. Measuring similarity between users/items for
binary prediction
Jaccard similarity
2. Measuring similarity between users/items for real-
valued prediction
cosine/Pearson similarity