Skip to content

premnadh/marketplace-recommendation-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Marketplace Recommendation Engine

Hybrid AI Recommendation System for Smart Product Discovery

Python Streamlit Machine Learning Scikit-Learn License

An AI-powered recommendation system that simulates how modern e-commerce platforms generate personalized product suggestions.

This project combines:

  • Collaborative Filtering (SVD Matrix Factorization)
  • Content-Based Filtering (TF-IDF + Cosine Similarity)

into a Hybrid Recommendation Engine, delivered through an interactive Streamlit application.


🎯 Project Objective

Design and implement a production-style recommendation system that:

  • Learns user preferences
  • Finds similar products
  • Ranks results intelligently
  • Simulates real-world product discovery systems

πŸ—οΈ System Architecture

The system follows a modular recommendation pipeline:

User Query / Interaction
        ↓
User History Extraction
        ↓
Candidate Generation
   β”œβ”€ Content-Based Filtering (TF-IDF)
   └─ Collaborative Filtering (SVD)
        ↓
Hybrid Ranking Engine
        ↓
Top-N Recommendations

πŸ”„ Recommendation Pipeline

graph TD
User[User Query] --> History[User Interaction Data]
History --> CF["Collaborative Filtering - SVD"]
User --> CB["Content-Based Filtering - TF-IDF"]
CF --> Hybrid[Hybrid Scoring]
CB --> Hybrid
Hybrid --> Output[Top-N Recommendations]
Loading

βš™οΈ Hybrid Scoring Formula

Final ranking score is computed as:

Final Score =
0.6 Γ— Collaborative Score
+
0.4 Γ— Content Similarity Score

This balances:

  • User behavior (collaborative filtering)
  • Product similarity (content-based filtering)

πŸ“Š Dataset

Dataset derived from:

Mercari Price Suggestion Challenge (Kaggle)
https://www.kaggle.com/c/mercari-price-suggestion-challenge

Dataset Characteristics

  • Users: ~10,000 (simulated interactions)
  • Products: ~2,500+
  • Features:
    • Product title
    • Category
    • Description
    • Price

βš™οΈ Data Preparation

Run:

python prepare_products.py

Generates:

data/products.csv
data/interactions.csv

Feature Engineering

  • Text preprocessing (cleaning titles/descriptions)
  • TF-IDF vectorization of product text
  • User-item interaction matrix construction
  • Normalisation of product metadata

These steps enable both content similarity and collaborative learning.


πŸ€– Recommendation Models

1️⃣ Content-Based Filtering

  • TF-IDF vectorisation
  • Cosine similarity
  • Captures product similarity

2️⃣ Collaborative Filtering

  • SVD (matrix factorization using Surprise library)
  • Learns user-item interaction patterns

3️⃣ Hybrid Recommendation

  • Combines both approaches
  • Produces more accurate and personalized results

πŸ”Ž Search & Ranking System

The system simulates a real-world search ranking pipeline:

User Query
    ↓
Candidate Retrieval (TF-IDF similarity)
    ↓
Ranking Model (SVD + Hybrid Score)
    ↓
Top-N Results

This mirrors how modern e-commerce systems rank search results.


πŸ“ˆ Evaluation Metrics

Recommendation quality can be evaluated using:

Metric Description
Precision@K Relevance of top-K recommendations
Recall@K Coverage of relevant items
MAP Mean Average Precision
NDCG Ranking quality

Example (simulated):

Precision@10: 0.82  
Recall@10: 0.74  
NDCG@10: 0.86  

πŸš€ Key Features

πŸ”Ž Smart Product Search

Users can search queries such as:

Nike running shoes
Jordan sneakers
Adidas ultraboost

Returns top-N ranked recommendations.


πŸ€– Hybrid Recommendation Engine

  • Combines collaborative + content-based filtering
  • Improves recommendation accuracy
  • Handles cold-start problems

πŸ–₯️ Interactive Web Interface

  • Product search
  • Trending recommendations
  • Product cards with images
  • External purchase links

🎯 Advanced Features

  • Price filtering
  • Category filtering
  • Sorting:
    • Best Match
    • Price Low β†’ High
    • Price High β†’ Low

πŸ“ˆ Example Workflow

User searches: "Nike running shoes"
        ↓
TF-IDF retrieves similar products
        ↓
SVD ranks based on user interactions
        ↓
Hybrid score computed
        ↓
Top recommendations displayed

🧩 Project Structure

marketplace-recommendation-engine
β”‚
β”œβ”€β”€ app
β”‚   └── streamlit_app.py
β”‚
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ similarity_search.py
β”‚   β”œβ”€β”€ collaborative_filtering.py
β”‚   β”œβ”€β”€ hybrid_recommender.py
β”‚   └── image_fetcher.py
β”‚
β”œβ”€β”€ data
β”‚   β”œβ”€β”€ products.csv
β”‚   └── interactions.csv
β”‚
β”œβ”€β”€ tests
β”‚
β”œβ”€β”€ prepare_products.py
β”œβ”€β”€ requirements.txt
└── README.md

⚑ Performance Considerations

To support scalability:

  • Precomputed TF-IDF vectors for fast similarity search
  • Efficient matrix factorization using SVD
  • Batch recommendation generation

Potential improvements:

  • Redis caching for frequent queries
  • FAISS / vector database for similarity search
  • Microservices-based recommendation system
  • Distributed model serving

▢️ Run Locally

Clone:

git clone https://github.com/premnadh/marketplace-recommendation-engine.git

Navigate:

cd marketplace-recommendation-engine

Create virtual environment:

python3.11 -m venv venv

Activate:

source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Run application:

streamlit run app/streamlit_app.py

Open:

http://localhost:8501

🌟 Key Highlights

  • Hybrid recommendation system
  • Real machine learning implementation
  • Search + ranking pipeline
  • Modular architecture
  • Interactive UI

πŸš€ Future Improvements

  • Deep learning recommendation models
  • Real-time personalization
  • Session-based recommendations
  • Advanced ranking algorithms
  • Cloud deployment (AWS / GCP)

πŸ‘€ Author

Prem Nadh Gajula

Aspiring Data Scientist | Machine Learning Engineer | Backend Developer


⭐ If you found this project useful, consider starring the repository!# premnadh

About

AI-powered hybrid product recommendation system that combines collaborative filtering and content-based similarity search to suggest relevant marketplace products based on user preferences and product features.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages