Recommender Systems: Collaborative Filtering, Content-Based Filtering, and Hybrid Approaches
Comprehensive guide to recommender systems, covering collaborative filtering, content-based filtering, and hybrid approaches, with practical implementation examples and best practices for building effective recommendation engines.
Anomaly Detection Using Gaussian Distribution: Detecting Outliers with Probability Models
Collaborative Filtering: Building Recommender Systems with Feature Learning
Recommender Systems
A recommender system predicts how users would rate items they have not yet rated.
Example:
- = number of users
- = number of movies
Users rate some movies (1–5 stars), but many ratings are missing.
Goal: predict the missing ratings.
Content-Based Idea
Each movie has features describing its content.
Example features:
- = romance level
- = action level
Example movie features:
| Movie | Romance () | Action () |
|---|---|---|
| Love at Last | 0.9 | 0 |
| Romance Forever | 1.0 | 0.01 |
| Swords vs Karate | 0 | 0.9 |
| Nonstop Car Chases | 0.1 | 1.0 |
| Cute Puppies of Love | 0.99 | 0 |
Each movie is represented by a feature vector:
The first element is the bias feature:
If we have features, then:
User Preference Model
Each user has their own parameter vector:
It represents the user's preferences for features.
Example:
- Alice likes romance → high weight on
- Bob likes action → high weight on
Rating Prediction
Predicted rating of user for movie :
This is just linear regression.
Example
Movie: Cute Puppies of Love
Feature vector:
Alice's preference vector:
Prediction:
Result:
Predicted rating ≈ 5 stars.
Cost Function
Single User
Let
- = user index
- = movie/ item index
Rating
- if user rated on movie , default =
- = rating by user on movie (if defined)
parameter vector for user j
- kind of movies liked by user
Predicted Rating
For use , movie predicted rating
For user , minimize squared error:
Where:
- = number of movies rated by user
Second term = regularization (prevents overfitting).
All Users
We learn parameters for all users:
Minimize this to learn all user preferences.
Optimization
Parameters are learned using:
- Gradient Descent
- or advanced optimizers (LBFGS, Conjugate Gradient)
Updates look similar to linear regression updates.
Why It's Called Content-Based
Because predictions depend on item features:
- romance
- action
- genre
- actors
- etc.
The system recommends items whose content matches the user's preferences.
Limitation
Requires hand-crafted features for items.
In many real systems:
- features are missing
- hard to define
This leads to the next method:
Collaborative Filtering.
