Real World Maths Busters

The Maths Behind Everyday Life

The story, the formula and a worked example — see exactly where this maths shows up in the world around you.

Back to all stories
Technology 4 min read

How Netflix guesses what you will watch next

Your taste becomes an arrow, and the app looks for arrows pointing the same way.

Recommendation engines turn your ratings into a list of numbers — a vector. Someone with similar taste has a vector pointing in nearly the same direction. The angle between two taste-vectors measures how alike two people are, and that is exactly what cosine similarity computes.

Taste as a direction

Cosine similarity ignores how much someone rates and looks only at the pattern. A value near 1 means "almost identical taste"; near 0 means "nothing in common".

cos⁡θ=a⋅b∥a∥ ∥b∥\cos\theta = \dfrac{\mathbf{a}\cdot\mathbf{b}}{\lVert\mathbf{a}\rVert\,\lVert\mathbf{b}\rVert}

You and a stranger

You rate three films 5, 1, 4. A stranger rates them 4, 1, 5. How alike are you?

Comparing [5, 1, 4] with [4, 1, 5]

  1. 1

    Dot product

    5×4+1×1+4×5=415\times4 + 1\times1 + 4\times5 = 41
  2. 2

    Each length

    52+12+42=42≈6.48\sqrt{5^2+1^2+4^2} = \sqrt{42} \approx 6.48
  3. 3

    Cosine similarity

    416.48×6.48≈0.976\dfrac{41}{6.48 \times 6.48} \approx 0.976
Answer

0.976 out of 1 — nearly identical taste, so whatever the stranger loved will likely be recommended to you.

The formula behind it

Cosine Similarity

cos⁡θ=A⋅B∥A∥ ∥B∥\cos\theta = \frac{A \cdot B}{\lVert A\rVert\,\lVert B\rVert}
See the full formula, variables and more examples

The takeaway

Recommendations are geometry in disguise: your preferences are a direction in space, and the service finds the people and films whose arrows point the same way.

Back to all stories