
Project 3: Building a Recommendation System
Master user-to-item and item-to-item recommendations. Build a movie or product recommender using vector similarity.
Project 3: Building a Recommendation System
Search is about finding what you know you want. Recommendations are about finding what you don't know you want yet. In this project, you will build a "Discover" feature for an app, using vector proximity to find similar items based on user behavior.
1. Project Requirements
- Data: A CSV of items (Movies, Products, or Articles) with tags and descriptions.
- Goal: Implement "More Like This" and "Recommended for You" logic.
2. Architecture: Two Approaches
Path A: Item-to-Item (Similarity Search)
- User is looking at "Product A".
- Get the vector for "Product A".
- Query the DB for the Top 5 most similar vectors (excluding Product A).
- Display: "Customers who viewed this also liked..."
Path B: User-to-Item (Profile Embedding)
- Look at the last 5 items a user liked.
- Mean Vector: Average the vectors of those 5 items to create a "User Interest Vector."
- Query the DB for items similar to the User Interest Vector.
- Display: "Recommended for You".
3. Implementation (Python)
import numpy as np
def push_recommendations(user_likes_ids, collection):
# 1. Fetch vectors for items the user liked
liked_items = collection.get(ids=user_likes_ids, include=['embeddings'])
vectors = liked_items['embeddings']
# 2. Compute the Average (The User's 'Taste' Vector)
user_taste_vec = np.mean(vectors, axis=0).tolist()
# 3. Find items close to that average
recommendations = collection.query(
query_embeddings=[user_taste_vec],
n_results=10,
# Don't recommend things they've already seen!
where={"id": {"$nin": user_likes_ids}}
)
return recommendations
4. Evaluation Criteria
- Diversity: Does the recommender show a variety of items, or just the same item 5 times?
- Relevance: Are the recommendations logically connected to the user's past likes?
- Latency: Does the "Taste Vector" calculation and search happen in under 150ms?
Deliverables
- A recommendation script that takes a "User History" list and outputs suggestions.
- A short paragraph on how you handled "Cold Start" (users with zero past likes).