Recommender systems are subclass of machine learning
Ranks predictions based on set of criteria
Two algorithms used for recommender systems are
- collaborative filtering
- 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".


Cost function

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


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.

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 filtering | Content based filtering |
|---|---|
| Recommends items to you based on ratings of users who gave similar ratings as you | Recommends 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


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


| Outputs | Description |
|---|---|
| Vᵤ | Latent vector that represents user in latent feature space |
| Vₘ | Latent vector that represents movie latent space |

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.
- For each of the last 10 movies watched by the users, find the 10 most similar movies
- For most viewed 3 genres, find top 10 movies
- 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:
- Movies most likely to be rated 5 stars by users
- Products most likely to be purchased
- Ads most likely to be clicked on
- Products generating the largest profit
- Video leading to maximum watching time

Principal component analysis
Idea is to find new axis and coordinates

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


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