TasteLens is a personalized food recommendation system that suggests food items based on individual preferences. The system leverages multiple machine learning models to analyze user behavior and item characteristics, enabling more accurate and diverse recommendations.
The project explores different recommendation strategies and combines them to improve personalization and recommendation quality.
A web interface was built to display recommendations, allowing users to browse popular dishes and see personalized suggestions generated by the ML models.
- Food platforms offer a wide range of choices, making it difficult for users to find dishes that match their personal preferences.
- Most recommendation systems rely on generic or popularity-based suggestions, which fail to capture individual tastes.
- Personalized food recommendation is challenging due to subjective user preferences and the lack of suitable, real-world food preference datasets.
- Using a single recommendation approach often results in biased or less accurate suggestions.
TasteLens aims to address these challenges by applying multiple machine learningβbased recommendation models and combining them through a hybrid approach to deliver more relevant and personalized food recommendations.
TasteLens follows a multi-model recommendation approach to deliver personalized food suggestions. Different recommendation techniques capture unique aspects of user behavior, and combining them improves overall recommendation quality.
- Recommends food items by analyzing item attributes and user preferences.
- Builds a preference profile for each user based on past interactions.
- Suggests food items with similar characteristics.
- Advantages: Effective personalization even when user interaction data is limited.
- Identifies users with similar taste patterns by comparing their rating behavior.
- Recommends items liked by similar users to the target user.
- Advantages: Introduces variety beyond a single userβs history by leveraging shared preferences.
- Focuses on relationships between food items rather than users.
- Items receiving similar ratings from multiple users are considered related.
- When a user interacts with a food item, similar items are recommended.
- Advantages: Stable and efficient recommendation generation.
- Combines content-based filtering with collaborative filtering techniques.
- Aggregates recommendations from individual models to produce the final output.
- Advantages: Reduces over-specialization, improves recommendation diversity, and provides balanced results compared to using a single model.
TasteLens is designed as a modular recommendation system, where each component transforms user preference data into meaningful food recommendations. The architecture supports multiple recommendation models and allows their outputs to be combined in a structured manner.
The system processes userβfood interaction data through a sequence of well-defined stages, ensuring accuracy, scalability, and clarity in recommendation generation.
-
User Preference Data Input
- Accepts user interaction data including user IDs, food item IDs, ratings, and basic item attributes.
- This data represents individual taste patterns and serves as the foundation for personalization.
-
Data Preprocessing and Preparation
- Cleans and standardizes raw data for consistency across models.
- Handles missing values, normalizes ratings, and transforms data into model-compatible formats.
-
Independent Model Training
- Each recommendation model (Content-Based, User-Based CF, Item-Based CF) is trained independently.
- Each model captures unique aspects of user behavior and item similarity.
-
Model-Specific Recommendation Generation
- Trained models generate individual recommendation lists based on their methodology.
- Each list reflects a different perspective on user preference and similarity.
-
Hybrid Recommendation Integration
- Aggregates recommendations from all models using a hybrid strategy.
- Balances personalization and diversity while reducing bias from any single model.
-
Final Recommendation Output
- Integrated recommendation list is presented as the final output.
- Delivers personalized and relevant food suggestions to users.
User Interaction Data
β
Data Preprocessing
β
Model Training (CBF | UBCF | IBCF)
β
Individual Recommendations
β
Hybrid Integration
β
Final Personalized RecommendationsThe dataset used in the TasteLens project consists of 1,500 records representing userβfood interactions. Each record captures detailed food attributes, nutritional information, user preferences, and contextual restaurant data. This enables the implementation of content-based, collaborative, and hybrid recommendation models.
Each row corresponds to a single interaction between a user and a food item, and includes the following attributes:
user_id: Unique identifier for each user
food_id: Unique identifier for each food itemdish_name: Name of the dishcuisine: Cuisine categorycourse: Type of course (starter, main, dessert, etc.)ingredients: Key ingredients used in the dishimg_url: URL of the dish image for visual representation
calories: Energy contentprotein_g,fat_g,carbs_g,fiber_g,sugar_g: Macronutrientssodium_mg: Sodium content
prep_time_min: Estimated preparation timediet_type: Dietary categoryallergies: Known allergensgoals: User dietary goals
rating: User ratingliked: Binary preference indicatortimes_ordered: Number of times ordered
restaurant_id: Unique identifierrestaurant_name: Name of the restaurantlocation: Restaurant locationcuisine_type: Cuisine offereddelivery_time: Estimated delivery timeaverage_cost: Average order cost
timestamp: Time of interaction
- Dish attributes and
img_urlsupport content-based recommendations and UI-level visualization. - Ratings and interaction data are used for collaborative filtering.
- Combined features contribute to the hybrid recommendation model.
The TasteLens dataset was preprocessed and transformed to extract meaningful features for all four recommendation models: Content-Based, User-Based Collaborative Filtering (UBCF), Item-Based Collaborative Filtering (IBCF), and Hybrid. The goal was to ensure that each model could effectively capture user preferences and item similarities.
- Feature Combination: Multiple text-based features were combined into a single representation with weighted importance:
combined = cuisine (2x) + diet_type (1.5x) + course + ingredients + goals- Missing Values: Filled any missing values in the combined text column with empty strings.
- Vectorization: Used
TfidfVectorizerto convert textual features into numerical vectors. - Similarity Calculation: Computed cosine similarity between dishes to identify similar items for each user.
- Relevant Columns: Extracted
user_id,dish_name, andrating. - Data Cleaning: Converted ratings to numeric and dropped rows with missing values.
- Index Mapping: Created numeric mappings for users and items to build a sparse user-item matrix.
- Similarity Computation: Applied cosine similarity on the transposed matrix (items Γ users) to measure item-item similarity.
- User-Item Matrix: Rows =
user_id, Columns =dish_name, Values =rating. - Missing Values: Handled appropriately to ensure matrix completeness.
- Similarity Computation: Applied cosine similarity on the user-item matrix to identify similar users.
- Evaluation: Split dataset into train and test sets to assess model performance.
- Approach: Combined explicit collaborative filtering (SVD-based) with content-based similarity features.
- Text Features: Concatenated
dish_name,cuisine, andrestaurant_nameand vectorized using TF-IDF. - Similarity Calculation: Computed cosine similarity for content-based features.
- SVD Collaborative Filtering: Trained model on user-food ratings using the
surpriselibrary. - Final Recommendations: Aggregated predictions from both approaches to generate robust recommendations.
- Preprocessing ensured all models received clean, structured, and meaningful input.
- Transformed text features, numerical ratings, and user interactions into model-compatible formats.
- Cosine similarity and matrix factorization (SVD) formed the backbone of the recommendation calculations.
The TasteLens project leverages frontend, backend, and machine learning technologies to deliver a complete food recommendation system.
- React.js β For building a responsive, dynamic user interface.
- JSX β To structure UI components and seamlessly integrate JavaScript with HTML.
- Python β Handles server-side logic, API requests, and ML model integration.
- Flask / FastAPI β Serves APIs that connect the frontend with machine learning models.
- Content-Based Filtering β Uses TF-IDF vectorization and cosine similarity.
- Collaborative Filtering (User-Based & Item-Based) β Computes cosine similarity on user-item matrices.
- Hybrid Model β Combines SVD-based collaborative filtering with content-based features.
- Pandas, NumPy β For data manipulation and preprocessing.
- Scikit-learn β For TF-IDF vectorization and similarity calculations.
- Surprise β Implements SVD collaborative filtering.
- Scipy (csr_matrix) β For sparse matrix operations in collaborative filtering.
The TasteLens system was evaluated using Precision@5, Recall@5, and F1 Score@5 metrics for all four recommendation models. These metrics measure how accurately the system recommends relevant dishes to users.
| Model | Precision@5 | Recall@5 | F1 Score@5 |
|---|---|---|---|
| Content-Based Filtering | 0.026 | 0.061 | 0.036 |
| User-Based Collaborative Filtering | 0.490 | 1.000 | 0.658 |
| Item-Based Collaborative Filtering | 0.5607 | 0.7791 | 0.6521 |
| Hybrid Recommendation | 0.6187 | 1.0000 | 0.7645 |
- Content-Based Filtering (CBF): Performs poorly due to limited user-specific feature information, resulting in low precision and recall.
- User-Based Collaborative Filtering (UBCF): Achieves high recall but moderate precision, indicating it recommends most relevant items but may include less precise suggestions.
- Item-Based Collaborative Filtering (IBCF): Balances precision and recall better than UBCF, showing effective similarity-based item recommendations.
- Hybrid Model: Outperforms all other models with the highest F1 Score, demonstrating that combining content-based and collaborative filtering techniques provides the most balanced and accurate recommendations.
- Individual models capture different aspects of user preferences, but a hybrid approach significantly improves overall recommendation quality.
- The system is capable of delivering personalized and relevant food suggestions despite limitations in dataset size and scope.
TasteLens demonstrates the effectiveness of a multi-model recommendation system for personalized food suggestions. By combining content-based filtering, user-based and item-based collaborative filtering, and a hybrid approach, the system can:
- Capture individual user preferences.
- Recommend items based on similar users and similar dishes.
- Balance personalization and diversity through hybrid aggregation.
- Content-Based Filtering (CBF) alone performs poorly due to limited user-specific features.
- Collaborative Filtering techniques (UBCF & IBCF) significantly improve recommendation quality.
- The Hybrid Model outperforms all individual approaches, achieving the highest F1 Score, highlighting that combining multiple strategies is crucial for accurate and relevant recommendations.
- Larger and Real-World Dataset: Incorporate a more extensive user dataset to improve model accuracy and generalization.
- Dynamic User Preferences: Use temporal modeling to capture changing tastes over time.
- Enhanced Personalization: Analyze user behavior, preferences, and context for highly tailored recommendations.
- Context-Aware Recommendations: Consider time of day, location, or dietary restrictions for smarter suggestions.
- Full-Fledged Website with Dashboards: Build a web platform with multiple dashboards for users, admins, and restaurants, providing a smooth and interactive experience.
- Integration with Live Platforms: Deploy TasteLens as a web or mobile app with real-time recommendation updates.
- Visual Recommendation Features: Use the
img_urlcolumn for image-based similarity or deep learning-driven recommendations.
- Unique Feature Ideas:
- Recipe Mood Match: Recommend dishes based on mood, weather, or cravings.
- Image-Based Search: Suggest dishes similar to a user-uploaded photo.
- Gamification / Rewards: Introduce points or achievements to increase engagement.
- Advanced Hybrid Techniques: Experiment with ensemble methods, deep learning, or graph-based recommendation models to further enhance recommendations.