Skip to content

A Hybrid Product Recommendation System (Collaborative + Content-Based) built with Python, NMF, Flask, and Streamlit. Capable of real-time <100ms inference. πŸš€

Notifications You must be signed in to change notification settings

prakash888kp/Real-Time-Product-Recommendation-system

Repository files navigation

Real-Time Product Recommendation System

A robust prototype of a real-time recommendation engine for e-commerce, capable of delivering personalized product suggestions using a Hybrid approach (Collaborative + Content-Based Filtering).

πŸš€ Features

  • Hybrid Recommendation Engine: Combines User Behavior (NMF) and Product Similarity (TF-IDF) for accurate suggestions.
  • Cold Start Handling: Uses Content-Based filtering for new users/products.
  • Real-Time API: Flask-based REST API with <100ms response time.
  • Interactive Dashboard: Streamlit UI for visualizing user profiles and recommendations.
  • Evaluation Metrics: Built-in script calculates Precision@K and Recall@K.
  • Scalable Design: Modular architecture ready for Spark/Kafka integration.

πŸ› οΈ Tech Stack

  • Language: Python 3.x
  • Machine Learning: Scikit-Learn (NMF, TF-IDF), NumPy, Pandas
  • API: Flask
  • Visualization: Streamlit
  • Data Processing: Pandas

πŸ“‚ Project Structure

β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ processed/          # Generated artifacts (interactions, models)
β”‚   β”œβ”€β”€ raw/                # Original CSV datasets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ models/             # ML Model implementations (Hybrid, NMF, Content)
β”‚   β”œβ”€β”€ app.py              # Flask API
β”‚   β”œβ”€β”€ dashboard.py        # Streamlit Dashboard
β”‚   β”œβ”€β”€ data_processing.py  # ETL Pipeline
β”‚   β”œβ”€β”€ feature_engineering.py # Feature extraction
β”‚   └── evaluate.py         # Metrics calculation
└── notebooks/              # Experimental notebooks

⚑ Quick Start

1. Setup Environment

pip install pandas numpy scikit-learn flask streamlit joblib requests

2. Prepare Data & Train Models

Run the pipeline to process data and train the initial models:

# 1. Process Raw Data
python src/data_processing.py

# 2. Extract Features & Create Embeddings
python src/feature_engineering.py

# 3. Train Collaborative Model (NMF)
python src/models/collaborative_sklearn.py

3. Run the API

Start the backend server:

python src/app.py

Server runs at http://localhost:5000

4. Run the Dashboard

Open the interactive UI:

streamlit run src/dashboard.py

πŸ“Š Evaluation

To check the model's performance metrics (Precision & Recall):

python src/evaluate.py

πŸ”— API Usage

Endpoint: GET /recommend/<user_id>

Example:

curl http://localhost:5000/recommend/C1003

Response:

{
  "user_id": "C1003",
  "strategy": "Hybrid",
  "recommendations": ["P2003", "P4012", "P1005", "P3001", "P2022"]
}

About

A Hybrid Product Recommendation System (Collaborative + Content-Based) built with Python, NMF, Flask, and Streamlit. Capable of real-time <100ms inference. πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages