18 min total

Machine Learning

Recommenders & PCA

Recommenders & PCA

Recommender systems are subclass of machine learning

Ranks predictions based on set of criteria

Two algorithms used for recommender systems are

  1. collaborative filtering
  2. content based

Collaborative filtering

Multiple users rating the same movies allows the algorithm to "collaborate" and infer movie features.

This collaboration enables predicting ratings for users who haven't rated certain movies.

Hence, the name "Collaborative Filtering".

Recommender systems and dimensionality reduction — illustration
Recommender systems and dimensionality reduction — illustration

Cost function

Recommender systems and dimensionality reduction — illustration

To learn parameters w(j) and b(j) for user j, minimize the regularized rating-prediction cost.

Recommender systems and dimensionality reduction — illustration
Recommender systems and dimensionality reduction — illustration

We will use gradient descent to minimize combined cost function with respect to w, b, and x

Binary labels

how to generalize the collaborative filtering algorithm to work with binary labels.

In many recommendation systems, instead of explicit ratings (e.g., star ratings), binary labels are used to indicate whether a user liked or engaged with an item.

a label of 1 may indicate that the user engaged with the item, while a label of 0 may indicate that the user did not engage with the item.

Binary labels can represent various user interactions, such as purchases, likes, favorites, or clicks.

To generalize the algorithm for binary labels, the logistic function (sigmoid function) is introduced to model the probability of engagement.

The probability of engagement (label 1) is predicted using the logistic function applied to the linear combination of weights and features.

Instead of the squared error cost function used in linear regression, the binary cross-entropy (or logistic loss) cost function is used for binary labels.

Recommender systems and dimensionality reduction — illustration

Mean normalization

Normalizing rows (not columns) for movie can make algorithms run more efficiently. Improves performance for users who have not rated any movies

Original cost function may predict a rating of zero for users who haven't rated any movie.

y(i,j) = row avg - each cell value

Column normalizations:

+ve) useful for brand new movies with no ratings


Row normalizations:

+ve) More important for handling new users

Collaborative filteringContent based filtering
Recommends items to you based on ratings of users who gave similar ratings as youRecommends items to you based on features of user and item to find good match

Content-based filtering

Recommends items based on features of users and items to find a good match

Uses features of users aswell as items to make recommendations

Requires feature vectors for each user and each item

Example features

Recommender systems and dimensionality reduction — illustration
Recommender systems and dimensionality reduction — illustration

Auto diff (automatic differentiation) in Tensorflow automatically computes gradients for optimization

The cold-start problem

How to rank new items that few users have rated

Show something reasonable to new users who have rated few items?

Neural content-based models

Recommender systems and dimensionality reduction — illustration
Recommender systems and dimensionality reduction — illustration
OutputsDescription
VᵤLatent vector that represents user in latent feature space
VₘLatent vector that represents movie latent space
Recommender systems and dimensionality reduction — illustration

Retrieval and ranking

If there are many movies (eg in billions), inference time every time a user enters the website becomes computationally expensive

Perform retrieval and ranking

Retrieval

Retrieve a large list of items for E.g.

  1. For each of the last 10 movies watched by the users, find the 10 most similar movies
  2. For most viewed 3 genres, find top 10 movies
  3. Top 20 movies in country

Combine retrieved items into a list, remove duplicates and items already watched/purchased

Ranking ~ 100s

Take list retrieved and rank using learned model

Display ranked items to user

Retreiving more items results in better performance but slower recommendations

To optimize tradeoff, carry out offline experiments to see if retreiving additional items results in more relevant recommendations

Recommendation objectives

To recommend:

  1. Movies most likely to be rated 5 stars by users
  2. Products most likely to be purchased
  3. Ads most likely to be clicked on
  4. Products generating the largest profit
  5. Video leading to maximum watching time
Recommender systems and dimensionality reduction — illustration

Principal component analysis

Idea is to find new axis and coordinates

Recommender systems and dimensionality reduction — illustration

PCA reduces the number of dimensions by transforming data into a new set of orthogonal (uncorrelated) features called principal components

Commonly used by data scientists to visualize the data in smaller dimensions, especially when the data is in thousand dimensions

PCA is not linear regression

Recommender systems and dimensionality reduction — illustration
Recommender systems and dimensionality reduction — illustration

In linear regression, algorithm fits the linear equation to the data by minimizing the difference between the predicted and actual values of

Normalize each table before applying PCA

Each dimension in PCA is called principal component

Best prinicpal component has the most variance in data points

+ve) Data compression, to reduce storage/ transmission costs

+ve) Speeding up training of supervised learning model