328
CHAPTER 9. RECOMMENDATION SYSTEMS
There is no harm if some components of the vectors are Boolean and others are
real-valued or integer-valued. We can still compute the cosine distance between
vectors, although if we do so, we should give some thought to the appropri-
ate scaling of the nonBoolean components, so that they neither dominate the
calculation nor are they irrelevant.
Example 9.2 : Suppose the only features of movies are the set of actors and
the average rating. Consider two movies with ﬁve actors each. Two of the
actors are in both movies. Also, one movie has an average rating of 3 and the
other an average of 4. The vectors look something like
0
1
1
0
1
1
0
1
3α
1
1
0
1
0
1
1
0
4α
However, there are in principle an inﬁnite number of additional components,
each with 0’s for both vectors, representing all the possible actors that neither
movie has. Since cosine distance of vectors is not aﬀected by components in
which both vectors have 0, we need not worry about the eﬀect of actors that
are in neither movie.
The last component shown represents the average rating. We have shown
it as having an unknown scaling factor α. In terms of α, we can compute the
cosine of the angle between the vectors. The dot product is 2 + 12α2, and the
lengths of the vectors are
√
5 + 9α2 and
√
5 + 16α2. Thus, the cosine of the
angle between the vectors is
2 + 12α2
√
25 + 125α2 + 144α4
If we choose α = 1, that is, we take the average ratings as they are, then
the value of the above expression is 0.816. If we use α = 2, that is, we double
the ratings, then the cosine is 0.940. That is, the vectors appear much closer
in direction than if we use α = 1. Likewise, if we use α = 1/2, then the cosine
is 0.619, making the vectors look quite diﬀerent. We cannot tell which value of
α is “right,” but we see that the choice of scaling factor for numerical features
aﬀects our decision about how similar items are.
✷
9.2.5
User Proﬁles
We not only need to create vectors describing items; we need to create vectors
with the same components that describe the user’s preferences. We have the
utility matrix representing the connection between users and items.
Recall
the nonblank matrix entries could be just 1’s representing user purchases or a
similar connection, or they could be arbitrary numbers representing a rating or
degree of aﬀection that the user has for the item.
With this information, the best estimate we can make regarding which items
the user likes is some aggregation of the proﬁles of those items. If the utility
matrix has only 1’s, then the natural aggregate is the average of the components
