Project 3: Building a Recommendation System

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)

  1. User is looking at "Product A".
  2. Get the vector for "Product A".
  3. Query the DB for the Top 5 most similar vectors (excluding Product A).
  4. Display: "Customers who viewed this also liked..."

Path B: User-to-Item (Profile Embedding)

  1. Look at the last 5 items a user liked.
  2. Mean Vector: Average the vectors of those 5 items to create a "User Interest Vector."
  3. Query the DB for items similar to the User Interest Vector.
  4. 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

  1. A recommendation script that takes a "User History" list and outputs suggestions.
  2. A short paragraph on how you handled "Cold Start" (users with zero past likes).

Building recommendation engines is the 'Secret Sauce' of modern platforms. Let's get started.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn