Back to Blog
•8 min read

How I Built a Dynamic Pricing ML System

Introduction

A Dynamic Pricing ML System that predicts optimal prices for retail products to maximize sales revenue. Built with LightGBM, Flask, and a beautiful web UI.

šŸŽÆ What Does This Project Do?

Given a product (identified by stockcode), this system predicts:

  • How many units will sell at different price points
  • What is the optimal price to maximize total revenue

Business Question:

"If I price product X at $Y, how many will I sell and what's my revenue?"

✨ Key Features

FeatureDescription
šŸ¤– ML ModelsLightGBM + ElasticNet ensemble for robust predictions
🌐 REST APIFlask-based API with CORS support
šŸŽØ Web UIBeautiful, responsive prediction interface
šŸ“Š VisualizationsInteractive charts showing price vs. sales curves
šŸš€ Production ReadyDocker support for AWS Lambda/SageMaker deployment
⚔ Fast Inference~1-2 seconds per prediction

šŸ—ļø System Architecture

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   Raw Data      │────→│  Data Pipeline  │────→│  Processed Data │
│  (CSV/Excel)    │     │  (Engineering)  │     │   (Parquet)     │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                        │
                                                        ↓
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”     ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   Predictions   │←────│   Flask API     │←────│  ML Models      │
│   (JSON/UI)     │     │   (Waitress)    │     │  (LightGBM)     │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜     ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Quick Start

bash
# Clone the repository
git clone https://github.com/danishsyed-dev/ml-sales-prediction.git
cd ml-sales-prediction

# Install dependencies
pip install -r requirements.txt

# Run the application
python application.py