Machine Learning in Practice: Recommendation Systems

Mahmoud Ayach
Tech Blog
Published in
3 min readSep 24, 2023

Diving into the world of machine learning, we often hear how these algorithms are a big part of our daily lives. But have we ever stopped to think about how the stuff we learn from books shows up on our apps and websites?

I’ve been wondering a lot about how recommendation systems work. We know that Facebook suggests friends based on our personality and history, but how does this data go from just tables to a list of friend suggestions?

Photo by Tech Daily on Unsplash

After looking into this, I’m excited to say that I’m starting to get the hang of it. This has made me think more about what I see online, my data privacy, and what I should share. I’ve put together a cool journey for you all, and it’s all about picking a movie on Netflix — who doesn’t love movie time?

From a Business Problem to a Math ML Problem

Everything starts with a business need. The main goal for Netflix is to keep their customers happy and entertained by showing movies they’d like. This can be seen as a binary problem: a movie gets a ‘1’ if it matches the customer’s taste and a ‘0’ if it doesn’t. Sound familiar? Yep, this is a basic classification problem in machine learning.

Diving Deeper into Features

We’ve got our labels sorted, but what about the features? This is where we need to put our thinking caps on! We have to identify a variety of factors that could play a role in making our predictions spot on. This includes user-specific, movie-specific, and cross-features that blend user and movie information.

Digging deeper, user features could include specifics like age, gender, and the genres of movies watched most frequently. Instead of just viewing history, we could look at the average rating given by the user, the time spent watching different genres, and the frequency of watching movies.

On the movie side, features can be more than genre and release year. We could consider the movie’s average rating, the popularity of the movie, and whether it has won any awards.

Cross features get interesting; they could include whether the user typically enjoys award-winning movies or if the user often watches movies from a specific genre that the movie belongs to. These combinations help tailor the recommendations to the user’s taste more closely.

Collect the Data and Train Your Model: Where the Fun Begins!

Alright, we’re getting to the fun part now! What we need to do next is head back to Netflix’s data and gather feature vectors. Each feature vector should include user, movie, and cross features. Here’s how it might look:

Feature Vector = [User Features, Movie Features, Cross Features]

For instance, a feature vector of dimension 10 might look like this:

[25, Male, 4.2, Action, Action, 2020, 4.5, Yes, Yes, Yes] 

For the following features:

  1. User Age: 25 (User Feature)
  2. User Gender: Male (User Feature)
  3. User Average Rating Given: 4.2 (User Feature)
  4. User Genre Preference: Action (User Feature)
  5. Movie Genre: Action (Movie Feature)
  6. Movie Release Year: 2020 (Movie Feature)
  7. Movie Average Rating: 4.5 (Movie Feature)
  8. Movie is Award-Winning: Yes (Movie Feature)
  9. User Prefers Award-Winning Movies: Yes (Cross Feature)
  10. User-Movie Genre Match: Yes (Cross Feature)

The label for each vector would be whether the user liked or disliked the movie, represented by 1 for like and 0 for dislike. This way, we build a dataset with feature vectors and labels, which will be the foundation for training our recommendation model!

Diving into Action: Utilizing the Data

Let’s dive right in and put this data to good use! Think about any binary classifier you’ve learned about in class — be it logistic regression, neural network, SVM, or decision tree.

Train it using the dataset we’ve built, and voila! You have a prediction model that can tell you whether any movie and any user are a good match. Isn’t that super exciting? With this model, we can start making personalized movie recommendations, enhancing the user’s viewing experience!

--

--

Mahmoud Ayach
Tech Blog

Data science and machine learning enthusiast. Delving deep into AI insights and sharing compelling narratives on Medium.