People Like You

A minimodule on recommendation systems. Two ways a machine decides what you see next.

The Row at the Top

Spotify built you a playlist you never asked for. Netflix put a row at the top of the screen before you typed anything. Amazon told you what people who bought this also bought. Different companies, different screens, the same move: a machine guessing what you want next.

Two very different machines can produce that guess. They are built on opposite ideas, and they fail in opposite ways. This module is about both.


Users Like You

Somewhere in the system there is a person who rated almost every film exactly the way you did. You agreed on six of them. Then that person raved about a seventh you have never seen. The machine hands it to you.

That is collaborative filtering. It never looks at the film. It does not know that Barbie is pink or that Top Gun has fighter jets. It knows that you and one other viewer keep agreeing, so whatever that viewer loved and you have not watched is a good bet. Your taste is defined by the company you keep.

It breaks in two ways. If nobody resembles you, it has nothing to offer. And if you just signed up and have rated nothing, it cannot find your neighbors at all. A new user is invisible to it. That second failure has a name, the cold-start problem, and it is the reason every app nags you to rate things the moment you arrive.

Interactive Demo
The Neighbor Finder

Rate these five films. The machine compares your votes to nine other viewers, finds the one most like you, and recommends a film they liked that you haven't rated.

A stranger rated the same six films almost exactly as you did, then raved about a seventh you have never seen. Recommending it to you is the core idea behind which method?

Movies Like That

Now forget the other viewers. You liked Encanto. The machine pulls up its sheet: animated, musical, original, leans female. It scans every other film for the same tags. Wicked shares three of them. It recommends Wicked, and it never consulted a single other person to do it. Just you and the feature sheet.

That is content-based filtering. It reads what a thing is made of and finds more things made of the same stuff. Here is the sheet it reads for our nine films:

It has one obvious flaw. It only ever shows you more of the same. Like one animated film and it serves you the rest of the animated films, then stops. Nothing surprising ever reaches you, because surprise is not on the sheet. This is how a feed quietly narrows to a single genre.

Interactive Demo
The Feature Matcher

Drag the features you like into the box. The list reranks by how many of your features each film has. The chips click, too, if you'd rather not drag.

Features
Features I like
Recommended for you
A brand new user signs up and has rated nothing. Which method can still recommend something the moment they click one film they like?

Same Seed, Two Paths

Give both machines the same starting point. You liked Top Gun: Maverick. Content-based reads the sheet: action, serious, live action, a sequel that leans male. It finds Spider-Man and Avatar and hands you more of that. Safe, predictable, the kind of thing you could have named yourself.

Collaborative ignores the sheet. It finds the viewers who rated Top Gun the way you did, then notices that half of them also loved Barbie, which shares not one feature with a fighter-jet movie. It hands you Barbie. You would never have asked for it.

One method shows you the nearest thing. The other shows you the surprising thing. Most real systems run both and blend the results, then spend years tuning the blend. The row at the top of your feed is that blend, decided for you, every time the page loads.


The Trick

Both demos ran the same move. The Neighbor Finder turned you into a row of likes and dislikes, then looked for the row most like yours. The Feature Matcher turned every film into a row of features, then looked for the rows closest to what you picked. Users, films, it makes no difference. Everything becomes a list of numbers.

Once two things are lists of numbers, you can measure how far apart they point. Close together means similar. The recommendation is whatever sits nearest to you that you have not seen yet. Collaborative filtering measures distance between people. Content-based filtering measures distance between things. Same ruler, different objects.

For the curious: how a machine measures taste

To compare two rows, the machine treats each one as a vector and measures the angle between them. Entries that only one row has are ignored. The score runs from 0 (nothing in common) toward 1 (pointing the same way):

$$\text{sim}(a, b) = \frac{\sum_i a_i\, b_i}{\sqrt{\sum_i a_i^2}\;\sqrt{\sum_i b_i^2}}$$

In the Neighbor Finder, the rows are viewers and the entries are ratings. In the Feature Matcher, the rows are films and the entries are feature flags. The formula does not care which. The smaller the angle, the stronger the match.

Source Code

This page and its demos live here:

https://github.com/i-yam/passt/tree/main/modules/people_like_you