10 Recommender Systems
Recommender Systems
Recommender systems are used to recommend items to users based on their preferences. These are the most commercially successful applications of machine learning.
Example
Users rate movies using zero to five stars.
Notation:
- $n_u$: number of users
- $n_m$: number of movies
- $r(i, j)$: if user $j$ has rated movie $i$ (1 if yes, 0 if no)
- $y(i, j)$: rating given by user $j$ to movie $i$
- $n$: number of features
- $m^{(j)}$: number of movies rated by user $j$
| Movie | Alice | Bob | Carol | Dave |
|---|---|---|---|---|
| Love at last | 5 | 5 | 0 | 0 |
| Romance forever | 5 | ? | ? | 0 |
| Cute puppies of love | ? | 4 | 0 | ? |
| Nonstop car chases | 0 | 0 | 5 | 4 |
| Swords vs. karate | 0 | 0 | 5 | ? |
Per-Item Features
The following features are available for each movie:
- $x^{(1)}$: how much a movie is a romance
- $x^{(2)}$: how much a movie is action
For user $j$: Predict rating for movie $i$ as: $w \cdot x^{(i)} + b$ For user $1$ and movie $3$: $w^{(1)} \cdot x^{(3)} + b = 4.95$
| Movie | $x^{(1)}$ | $x^{(2)}$ |
|---|---|---|
| Love at last | 0.9 | 0 |
| Romance forever | 1.0 | 0.01 |
| Cute puppies of love | 0.99 | 0 |
| Nonstop car chases | 0.1 | 1.0 |
| Swords vs. karate | 0 | 0.9 |
Cost Function
To learn $w^{(j)}$ and $b^{(j)}$ minimize the cost function.
$$ J(w^{(j)}, b^{(j)}) = \frac{1}{2m^{(j)}} \sum_{i:r(i, j)=1} (w^{(j)} \cdot x^{(i)} + b^{(j)} - y^{(i, j)})^2 + \frac{\lambda}{2m^{(j)}} \sum_{k=1}^n (w_k^{(j)})^2 $$
and generalized to all users:
$$ J(w^{(1)}, b^{(1)}, \ldots, w^{(n_u)}, b^{(n_u)}) = \frac{1}{2} \sum_{j=1}^{n_u} \sum_{i:r(i, j)=1} (w^{(j)} \cdot x^{(i)} + b^{(j)} - y^{(i, j)})^2 + \frac{\lambda}{2} \sum_{j=1}^{n_u} \sum_{k=1}^n (w_k^{(j)})^2 $$
Collaborative Filtering
Collaborative filtering is based on the idea that users who agreed in the past will agree in the future. It will recommend items based on ratings of other users who gave similar ratings.
Content-Based Filtering
Content-based filtering is based on the idea that users will like items similar to the ones they liked in the past. It will recommend items based on features of user and item to find a good match.
Ethics
Recommender systems can be used to recommend:
- Movies most likely to be rated 5 stars
- Products most likely to be purchased
- Ads most likely to be clicked on
- Products generating the largest profit
- Videos leading to longest watch time
There are pros and cons to each of these recommendations.