30 Days of Algorithms: From Zero to Intermediate (30/30) — K-Nearest Neighbors

Tomas Svojanovsky
3 min readJun 5, 2024

Building a recommendations system

You just subscribed to Netflix and have watched a few movies. You’re curious how they recommend new content.

Netflix uses a system that identifies people with similar viewing habits to you. By analyzing what those users enjoy, Netflix can suggest movies you might also like.

Movies example

Have you wondered why Netflix asks you to rate this movie? It helps them decide whether to recommend it to you or not.

Now we will take the movies by genre and count how many movies we like in each genre. We will calculate the distance between you and your friends. The smaller the number, the better.

Liked movies by genre

You and friend 1

We will take each number in the groups (5, 4, 3) and (4, 3, 5), find the difference between them, square the differences, and then take the square root of the sum of these squared differences.

--

--

Tomas Svojanovsky

I'm a full-stack developer. Programming isn't just my job but also my hobby. I like developing seamless user experiences and working on server-side complexities