AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Recommendation Systems: How Netflix, Spotify, and Flipkart Know What You Want

📚 Machine Learning⏱️ 19 min read🎓 Grade 9
✍️ AI Computer Institute Editorial Team Updated: August 2026 CBSE-aligned · Peer-reviewed · 19 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

Same Age, Same Show, Completely Different Homepage

Suppose you and your best friend are both 14, both finished watching Money Heist last week, and both open Netflix on a Saturday morning. Your homepage leads with a Korean thriller. Her homepage leads with a K-drama romance. Neither of you searched for anything — the app just decided, on its own, what to put at the very top of the screen where your thumb lands first.

This is not a coincidence and it is not magic. It is the output of an algorithm doing a very specific, very learnable calculation: given everything the app knows about you, which of the thousands of available items is most likely to make you stay and watch (or listen, or buy)? That algorithm is called a recommendation system, and by the end of this chapter you will be able to compute, by hand, the exact kind of number that decides what shows up first on your screen.

There are two fundamentally different strategies a recommendation system can use, and real products like Netflix, Spotify, and Flipkart combine both. We will build each one from a worked numeric example, because the formulas mean nothing until you have done the arithmetic yourself at least once.

Strategy 1: "Show Me More Of What I Already Liked" — Content-Based Filtering

Imagine a very small streaming catalogue with just three films, and imagine we score every film on two properties, each from 0 to 6: how much action it has, and how much romance it has.

  • RRR — Action: 5, Romance: 1
  • War (2019) — Action: 4, Romance: 2
  • Kabir Singh — Action: 1, Romance: 5

Each film is now a pair of numbers — mathematically, a vector. You just finished RRR and rated it five stars. Which of the other two films should the app push to your homepage next: War, or Kabir Singh?

Your instinct probably says War, because it also leans heavily toward action. The question is: how does a computer turn that instinct into an exact number it can rank films by? It cannot say "these feel similar." It needs arithmetic.

Turning "Similar" Into a Number: Cosine Similarity

The tool for this is called cosine similarity. Despite the intimidating name, the idea is simple: plot each film as an arrow (a vector) starting from the origin, and measure the angle between two arrows. Two arrows pointing in nearly the same direction are "similar" films, regardless of how long the arrows are. Two arrows pointing in very different directions are dissimilar, even if they happen to be the same length.

The formula that produces this angle-based score, for two vectors a and b, is:

cosine_similarity(a, b) = (a . b) / (|a| * |b|)

Here, a . b is the dot product — multiply matching components and add them up — and |a| is the magnitude (length) of the vector, found with the Pythagorean-style formula sqrt(x^2 + y^2). The result is always a number between -1 and 1. A value near 1 means "pointing almost the same way" (very similar). A value near 0 means "pointing in unrelated directions." Let's compute it by hand for RRR versus War before touching any code.

Step 1 — dot product of RRR (5, 1) and War (4, 2): (5 x 4) + (1 x 2) = 20 + 2 = 22.

Step 2 — magnitude of RRR: sqrt(52 + 12) = sqrt(25 + 1) = sqrt(26) ≈ 5.099.

Step 3 — magnitude of War: sqrt(42 + 22) = sqrt(16 + 4) = sqrt(20) ≈ 4.472.

Step 4 — divide: 22 / (5.099 x 4.472) = 22 / 22.80 ≈ 0.965.

Now RRR (5, 1) versus Kabir Singh (1, 5): dot product = (5 x 1) + (1 x 5) = 10. Magnitude of Kabir Singh = sqrt(1 + 25) = sqrt(26) ≈ 5.099 — the exact same length as RRR's vector, notice. Cosine similarity = 10 / (5.099 x 5.099) = 10 / 26.00 ≈ 0.385.

The numbers confirm the instinct precisely: War scores 0.965 (almost pointing the same way as RRR), while Kabir Singh scores only 0.385, even though its vector is exactly as long as RRR's. Length alone tells you nothing about taste-similarity — direction does. That is the entire point of dividing by the magnitudes: it cancels out length and leaves only angle.

Action Romance 1 2 3 4 5 6 1 2 3 4 5 6 RRR (5,1) War (4,2) Kabir Singh (1,5) cos(RRR, War) ≈ 0.965 cos(RRR, Kabir Singh) ≈ 0.385 Same arrow length, very different angle

Here is the same computation as runnable Python. Trace it line by line before reading the output.

def dot(a, b):
    return sum(x * y for x, y in zip(a, b))

def magnitude(v):
    return dot(v, v) ** 0.5

def cosine_similarity(a, b):
    return dot(a, b) / (magnitude(a) * magnitude(b))

rrr = [5, 1]          # [action, romance]
war = [4, 2]
kabir_singh = [1, 5]

print(round(cosine_similarity(rrr, war), 3))          # 0.965
print(round(cosine_similarity(rrr, kabir_singh), 3))  # 0.385

This is exactly what a content-based recommender does, just scaled up from 2 attributes to hundreds — genre tags, cast, director, keywords extracted from the plot, even the dominant colour palette of the thumbnail. Every item becomes a long vector, and the system ranks unseen items by their cosine similarity to items you already rated highly.

Strategy 2: "People Like You Also Liked This" — Collaborative Filtering

Content-based filtering has a limitation: it only ever looks at an item's own properties. It will never recommend something outside your established taste, even if it is exactly the kind of surprising discovery you'd love. Collaborative filtering takes a completely different approach — it ignores what a film is about and instead asks who rated things the way you did.

Suppose four viewers — you, Aisha, Rohan, and Meera — have rated three films out of 5 stars:

  • You: RRR = 5, Kabir Singh = 2, War = 4, 3 Idiots = not yet watched
  • Aisha: RRR = 5, Kabir Singh = 1, War = 5, 3 Idiots = 5
  • Rohan: RRR = 2, Kabir Singh = 5, War = 2, 3 Idiots = 3
  • Meera: RRR = 1, Kabir Singh = 5, War = 1, 3 Idiots = 2

You haven't seen 3 Idiots. Should the app recommend it? Collaborative filtering answers this in two stages: first, find which other viewers rate films the way you do; second, let those viewers "vote" on your behalf, weighted by how similar they are to you.

Notice something important here: the exact same cosine-similarity formula from the last section works again, just on a different kind of vector. Instead of a film's genre scores, we now use a person's rating pattern across the three films you both watched.

You vs Aisha — vectors (5, 2, 4) and (5, 1, 5). Dot product = 25 + 2 + 20 = 47. Magnitude of your vector = sqrt(25+4+16) = sqrt(45) ≈ 6.708. Magnitude of Aisha's vector = sqrt(25+1+25) = sqrt(51) ≈ 7.141. Cosine similarity = 47 / (6.708 x 7.141) ≈ 0.981 — almost identical taste.

You vs Rohan — (5,2,4) and (2,5,2). Dot product = 10+10+8 = 28. Rohan's magnitude = sqrt(4+25+4) = sqrt(33) ≈ 5.745. Similarity = 28 / (6.708 x 5.745) ≈ 0.727.

You vs Meera — (5,2,4) and (1,5,1). Dot product = 5+10+4 = 19. Meera's magnitude = sqrt(1+25+1) = sqrt(27) ≈ 5.196. Similarity = 19 / (6.708 x 5.196) ≈ 0.545.

Aisha is by far your closest match. Now we predict your rating for 3 Idiots as a weighted average of what the others rated it, where each person's vote is weighted by their similarity to you — Aisha's opinion should count for much more than Meera's.

similarities = {"Aisha": 0.981, "Rohan": 0.727, "Meera": 0.545}
their_ratings_for_3_idiots = {"Aisha": 5, "Rohan": 3, "Meera": 2}

weighted_sum = sum(similarities[p] * their_ratings_for_3_idiots[p] for p in similarities)
total_weight = sum(similarities.values())
predicted_rating = weighted_sum / total_weight

print(round(predicted_rating, 2))   # 3.63

Trace it: weighted_sum = (0.981 x 5) + (0.727 x 3) + (0.545 x 2) = 4.905 + 2.181 + 1.090 = 8.176. total_weight = 0.981 + 0.727 + 0.545 = 2.253. predicted_rating = 8.176 / 2.253 ≈ 3.63. The system predicts you'd rate 3 Idiots about 3.6 out of 5 — solidly positive, so it earns a spot on your homepage, though not necessarily the very top slot. Crucially, no one told the algorithm anything about what 3 Idiots is about — no genre tags, no plot description. It made the prediction purely from the pattern of who agrees with whom, which is why this approach is called "collaborative": the recommendation for you is built collaboratively out of everyone else's ratings.

Common Misconception: "It Must Be Watching or Listening to Me"

A widely repeated myth among students is that apps like Netflix or Spotify use your phone's camera or microphone to figure out your mood or who's in the room, and recommend based on that. This is false, and it is worth correcting precisely because it distracts from what actually powers these systems. The real inputs are entirely behavioral and explicit data you generate through normal use: star ratings, watch history, search queries, how long you watched before stopping, whether you skipped a song in the first 10 seconds, what time of day you use the app, and what device you're on. None of this requires audio or video surveillance — it is the pattern in the numbers, exactly like the rating vectors above, scaled to millions of users and items. The mathematics you just did by hand — dot products, magnitudes, weighted averages — is a faithful miniature of what actually decides your homepage, not a simplification that hides some other hidden mechanism.

A second, more technical misconception worth naming: many students assume that "more overlap in raw numbers" automatically means "more similar taste" — for instance, that a large dot product alone proves two users are alike. The RRR-vs-Kabir-Singh example already refuted this once for item vectors, and it applies equally to people: someone who rates everything 5 stars will have large dot products with everyone, not because their taste matches, but because their ratings are big numbers. Dividing by the magnitudes, as cosine similarity does, is precisely what corrects for this — it measures agreement in pattern, not agreement in raw scale.

The Cold Start Problem

Both strategies share a weakness that has a specific name in computer science: the cold start problem. Content-based filtering needs you to have rated at least a few things before it can find similar items — a brand-new user with zero history gives it nothing to work from. Collaborative filtering needs an item to have been rated by someone before it can be recommended to anyone else — a movie released five minutes ago, with zero ratings, is invisible to the "people like you" calculation entirely, no matter how good it is.

Real platforms handle this with a mix of fallbacks: showing new users the most popular items overall until enough personal data accumulates; using content-based similarity to place a brand-new film near others of its genre even before ratings exist; and asking new users a short onboarding quiz ("pick a few shows you like") specifically to seed the very first vectors. Systems that blend content-based and collaborative signals together, rather than relying on just one, are called hybrid recommenders — this is what Netflix, Spotify, and Flipkart all actually run in production, because each strategy patches the other's blind spot.

At the scale of tens of millions of users and items, computing every pairwise cosine similarity by hand-style loops like ours would be far too slow. Large-scale systems instead use a technique called matrix factorization, which compresses the giant user-item ratings table into a much smaller set of learned numbers per user and per item — conceptually similar to the "action/romance" vectors we invented by hand, except the computer learns which hidden dimensions matter, and there might be 50 or 100 of them instead of just 2. The underlying similarity math, however, is the same idea you just computed with pencil and paper.

Check Your Understanding

  1. Two songs are represented as vectors [tempo, energy] = (8, 2) and (4, 1). Without calculating, predict whether their cosine similarity will be closer to 1 or closer to 0, and explain why using the idea of "angle versus length."
  2. A user's ratings vector for three movies is (4, 4, 4) and another user's is (1, 1, 1). Compute the cosine similarity between them by hand. What does the surprisingly high result reveal about a weakness of cosine similarity when ratings only reflect enthusiasm level rather than a mix of likes and dislikes?
  3. A streaming app just launched in India yesterday with 200 brand-new users and 50 brand-new regional films, none of which have any ratings yet. Which specific problem does this describe, and name two concrete fixes a real engineering team could ship this week.
  4. Explain in one or two sentences why collaborative filtering can recommend an item to you that shares no genre, cast, or keyword with anything you've ever watched, while content-based filtering cannot.

Answers: (1) Closer to 1 — both vectors point in almost the same direction (roughly a 4-to-1 tempo-to-energy ratio in both), even though the second vector is half as long; cosine similarity ignores length and measures only direction. (2) Dot product = 4+4+4=12, magnitude of (4,4,4) = sqrt(48)≈6.928, magnitude of (1,1,1) = sqrt(3)≈1.732, cosine similarity = 12/(6.928×1.732) = 12/12.0 = 1.0 — a perfect similarity score, even though one user loved everything and the other was lukewarm about everything; cosine similarity only compares the ratio between ratings, not their absolute enthusiasm, so a "loves everything a little" user and a "loves everything a lot" user look identical to it. (3) This is the cold start problem, hitting both sides at once (new users and new items); fixes include showing new users a popularity-based or editorially curated list until they generate a few ratings, and using content-based tags (genre, language, cast) to place the new regional films near similar existing titles so they aren't invisible to collaborative filtering. (4) Collaborative filtering recommends based on the rating patterns of similar people, not on the item's own attributes, so it can surface something with completely different content simply because people who share your taste happened to also like it — content-based filtering, by definition, can only ever recommend items that resemble what you've already rated.

Summary

A recommendation system decides what to show you by turning "similarity" into an exact, computable number. Content-based filtering represents items as vectors of their own attributes and ranks unseen items by cosine similarity to items you liked. Collaborative filtering represents people as vectors of their ratings and predicts your opinion of an unrated item as a similarity-weighted average of what similar people rated it. Both rely on the same core formula — dot product divided by the product of magnitudes — because both need to measure agreement in pattern, not raw scale, which is why a bigger number of shared ratings or a bigger dot product does not by itself mean two things are alike. Both strategies fail on brand-new users or brand-new items (the cold start problem), which is exactly why production systems like Netflix, Spotify, and Flipkart run hybrids of both, backed by popularity fallbacks and onboarding data, rather than relying on either idea alone. Nothing in this chapter involved cameras, microphones, or guesswork — every recommendation you have ever seen is the output of arithmetic you can now perform yourself with a pencil.

Practice Exercises

Now it is time to practice! Complete these challenges to solidify your understanding:

  • Exercise 1: Write a short program that demonstrates the core concept from this chapter. Test it with at least 3 different inputs.
  • Exercise 2: Find a real-world example where recommendation systems: how netflix, spotify, and flipkart know what you want is used in an Indian company (like TCS, Infosys, Flipkart, or ISRO). Write a paragraph explaining the connection.
  • Exercise 3: Create a mind-map connecting recommendation systems: how netflix, spotify, and flipkart know what you want to at least 3 other topics you have studied.
← Sentiment Analysis: Understanding OpinionsIntroduction to Computer Graphics and 3D Rendering →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn