3.1. APPLICATIONS OF SET SIMILARITY
77
Movie Ratings
Netﬂix records which movies each of its customers rented, and also the ratings
assigned to those movies by the customers. We can regard movies as similar
if they were rented or rated highly by many of the same customers, and see
customers as similar if they rented or rated highly many of the same movies.
The same observations that we made for Amazon above apply in this situation:
similarities need not be high to be signiﬁcant, and clustering movies by genre
will make things easier.
When our data consists of ratings rather than binary decisions (bought/did
not buy or liked/disliked), we cannot rely simply on sets as representations of
customers or items. Some options are:
1. Ignore low-rated customer/movie pairs; that is, treat these events as if
the customer never watched the movie.
2. When comparing customers, imagine two set elements for each movie,
“liked” and “hated.” If a customer rated a movie highly, put “liked” for
that movie in the customer’s set. If they gave a low rating to a movie, put
“hated” for that movie in their set. Then, we can look for high Jaccard
similarity among these sets. We can use a similar trick when comparing
movies.
3. If ratings are 1-to-5-stars, put a movie in a customer’s set n times if
they rated the movie n-stars. Then, use Jaccard similarity for bags when
measuring the similarity of customers. The Jaccard similarity for bags
B and C is deﬁned by counting an element n times in the intersection if
n is the minimum of the number of times the element appears in B and
C. In the union, we count the element the sum of the number of times it
appears in B and in C.2
Example 3.2 : The bag-similarity of bags {a, a, a, b} and {a, a, b, b, c} is 1/3.
The intersection counts a twice and b once, so its size is 3. The size of the
union of two bags is always the sum of the sizes of the two bags, or 9 in this
case. Since the highest possible Jaccard similarity for bags is 1/2, the score
of 1/3 indicates the two bags are quite similar, as should be apparent from an
examination of their contents.
✷
2Although the union for bags is normally (e.g., in the SQL standard) deﬁned to have the
sum of the number of copies in each of the two bags, this deﬁnition causes some inconsistency
with the Jaccard similarity for sets. Under this deﬁnition of bag union, the maximum Jaccard
similarity is 1/2, not 1, since the union of a set with itself has twice as many elements as the
intersection of the same set with itself. If we prefer to have the Jaccard similarity of a set
with itself be 1, we can redeﬁne the union of bags to have each element appear the maximum
number of times it appears in either of the two bags. This change also gives a reasonable
measure of bag similarity.
