Exercise 3: Dot Product as User-Similarity, and Its Scaling Problem — Possible Solution ==================================================================== GIVEN ------------------------------ user_x = [5, 1, 0] user_y = [4, 2, 1] STEP 1: THE DOT PRODUCT ------------------------------ user_x . user_y = (5 x 4) + (1 x 2) + (0 x 1) = 20 + 2 + 0 = 22 WHAT A HIGH DOT PRODUCT SUGGESTS ------------------------------ Per this chapter's own finding box, the dot product of two feature vectors is the mathematical basis for "how similar are these two things." A relatively high dot product here suggests user_x and user_y tend to rate the same genres highly at the same time - both rate the first genre highly (5 and 4), which dominates the sum, while the third genre (0 and 1) contributes almost nothing to the total. WHY A RAW DOT PRODUCT CAN BE MISLEADING ------------------------------ The dot product's size is directly affected by each vector's own magnitude, not just the *direction* the ratings point in. A user who rates everything near the maximum (say, [5, 5, 5]) will produce a large dot product with almost anyone, simply because their own numbers are large - not necessarily because their taste genuinely lines up with the other user's. Two users with identical *proportions* of preference (e.g. [1, 5, 1] and [2, 10, 2] - the second is just the first doubled) would get a large dot product purely from one user rating everything twice as enthusiastically, even though their tastes are, proportionally, identical. HOW NORMALIZING FIRST FIXES THIS ------------------------------ Dividing each vector by its own magnitude before taking the dot product (this chapter's own normalization operation) removes each user's own overall rating intensity from the calculation, leaving only the direction - the relative pattern of preference across genres. This is exactly cosine similarity: the dot product of the two normalized vectors, which depends only on the angle between them and stays unaffected by how enthusiastically either user rates things overall. WHY THIS WORKS AS AN ANSWER ------------------------------ It computes the dot product directly from this chapter's own formula, interprets the result using the chapter's own "dot product as similarity" finding, and explains the scaling problem with a concrete counterexample (proportionally identical but differently-scaled vectors) before connecting the fix directly back to this chapter's own normalization operation.