Spaces:
Sleeping
Sleeping
Initial implementation of TasteEngine: multi-approach recommender system with Flask web UI, evaluation suite, and explanation engine
133a630 |
Download plan/04-content-based.md from Abdallah4Zain/TasteEngine: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/spaces/Abdallah4Zain/TasteEngine/resolve/main/plan/04-content-based.md
- Command line
-
hf download hf://spaces/Abdallah4Zain/TasteEngine/plan/04-content-based.md
-
curl -L -o 04-content-based.md https://huggingface.co/spaces/Abdallah4Zain/TasteEngine/resolve/main/plan/04-content-based.md
1.97 kB
Content-Based Recommendation Plan
Overview
Content-Based Filtering recommends items based on the similarity between item features and user preferences. It does not rely on other users' data.
Method 1: TF-IDF + Cosine Similarity
Concept: Vectorize product descriptions/categories using TF-IDF, compute cosine similarity between items and user profile.
Steps:
- Build TF-IDF matrix from product descriptions + categories
- Build user profile vector (average of TF-IDF vectors of items the user rated highly)
- Compute cosine similarity between user profile and all items
- Recommend top-N most similar items not yet interacted with
Example:
User liked: "Samsung Galaxy S24" (Electronics, Smartphone)
Recommended: "iPhone 15 Pro" (cosine sim: 0.87) because same category
Method 2: Feature-Based Matching
Concept: Match items to user preferences using structured features (category, brand, price range).
Steps:
- Extract user preferences: preferred_categories, favorite_brands, budget
- Score each item based on feature match:
- Category match: +40 points
- Brand match: +30 points
- Price in range: +20 points
- Subcategory match: +10 points
- Recommend top-N highest scoring items
When it works best: Cold-start users (no rating history), user explicitly sets preferences
Implementation (recommender/content_based.py)
class ContentBasedRecommender:
def __init__(self, products_df):
self.products = products_df
self.tfidf_matrix = None
self.tfidf_vectorizer = None
def tfidf_recommend(self, user_id, user_preferences, n=10): ...
def feature_match_recommend(self, user_preferences, n=10): ...
def build_user_profile(self, rated_items): ...
Explanation Generation
- TF-IDF: "Recommended because it matches items you've liked before (similarity: {score}%)"
- Feature: "Recommended because it matches your preferred category: {category}"