UPDATED BY
Brennan Whitfield | Oct 11, 2022

These days whether you look at a video on YouTube, a movie on Netflix or a product on Amazon, you’re going to get recommendations for more things to view, like or buy. You can thank the advent of machine learning algorithms and recommender systems for this development. 

What Is Collaborative Filtering?

Collaborative filtering filters information by using the interactions and data collected by the system from other users. It’s based on the idea that people who agreed in their evaluation of certain items are likely to agree again in the future.

Recommender systems are far-reaching in scope, so we’re going to zero in on an important approach called collaborative filtering, which filters information by using the interactions and data collected by the system from other users. It’s based on the idea that people who agreed in their evaluation of certain items are likely to agree again in the future.

 

A Quick Primer on Recommender Systems

A recommender system is a subclass of information filtering that seeks to predict the “rating” or “preference” a user will give an item, such as a product, movie, song, etc.

Recommender systems provide personalized information by learning the user’s interests through traces of interaction with that user. Much like machine learning algorithms, a recommender system makes a prediction based on a user’s past behaviors. Specifically, it’s designed to predict user preference for a set of items based on experience.

Mathematically, a recommendation task is set to be:

  • Set of users (U)
  • Set of items (I) that are to be recommended to U
  • Learn a function based on the user's past interaction data that predicts the likeliness of item I to U

Recommender systems are broadly classified into two types based on the data being used to make inferences:

  1. Content-based filtering, which uses item attributes.
  2. Collaborative filtering, which uses user behavior (interactions) in addition to item attributes.

Some key examples of recommender systems at work include:

  • Product recommendations on Amazon and other shopping sites
  • Movie and TV show recommendations on Netflix
  • Article recommendations on news sites

 

How Recommender Systems Work (Netflix/Amazon) | Video: Art of the Problem

 

What Is Collaborative Filtering?

Collaborative filtering filters information by using the interactions and data collected by the system from other users. It’s based on the idea that people who agreed in their evaluation of certain items are likely to agree again in the future.

The concept is simple: when we want to find a new movie to watch we’ll often ask our friends for recommendations. Naturally, we have greater trust in the recommendations from friends who share tastes similar to our own.

Most collaborative filtering systems apply the so-called similarity index-based technique. In the neighborhood-based approach, a number of users are selected based on their similarity to the active user. Inference for the active user is made by calculating a weighted average of the ratings of the selected users.

Collaborative-filtering systems focus on the relationship between users and items. The similarity of items is determined by the similarity of the ratings of those items by the users who have rated both items.

There are two classes of Collaborative Filtering: 

  • User-based, which measures the similarity between target users and other users.
  • Item-based, which measures the similarity between the items that target users rate or interact with and other items.

 

Collaborative Filtering Using Python 

Collaborative methods are typically worked out using a utility matrix. The task of the recommender model is to learn a function that predicts the utility of fit or similarity to each user. The utility matrix is typically very sparse, huge and has removed values.

In the following matrices, each row represents a user, while the columns correspond to different films by Pixar. The cosine similarity is the simplest algorithm needed to find the similarity of the vectors. The last, which is the utility matrix following the first matrix, contains only partial data, which is needed to predict the likeliness of the expected rating by the “root” that could be given by the user.

In the following matrices, each row represents a user, while the columns correspond to different movies, except the last one which records the similarity between that user and the target user. Each cell represents the rating that the user gives to that movie.

cosine_similarity(p, q) = p.q

____

|p|.|q|

collaborative filtering table

cosine_similarity(joe, beck) =

collaborative filtering with python

When a new user joins the platform, we apply the simplest algorithm that computes cosine or correlation similarity of rows (users) or columns (movies) and recommends items that are k-nearest neighbors.

CF table 2

These are many equations that can deal with the question of similarity measures, a few include:

  • Pearson similarity
  • Jaccard similarity
  • Spearman rank correlation
  • Mean squared differences
  • Proximity–impact–popularity similarity
Expert Contributors

Built In’s expert contributor network publishes thoughtful, solutions-oriented stories written by innovative tech professionals. It is the tech industry’s definitive destination for sharing compelling, first-person accounts of problem-solving on the road to innovation.

Learn More

Great Companies Need Great People. That's Where We Come In.

Recruit With Us