OptimaPrice is an end-to-end Machine Learning-powered pricing engine that predicts and optimizes e-commerce product prices in real-time. By leveraging historical sales signals, competitor indices, and inventory levels, the system implements AI-driven pricing strategies responsive to fluctuating market demand.
- Three ML Model Architectures:
- Ridge Regression: High-speed baseline model.
- Random Forest Regressor: Ensembled decision tree for non-linear relations (highest accuracy).
- PyTorch Multi-Layer Perceptron (MLP): Deep learning network capturing deep interactions.
- Feature Engineering Pipeline: Extracts signals including competitor price differentials, price-to-cost margins, and inventory-to-demand availability ratios.
- Flask REST API: Serves predictions (
/api/predict), validation metrics (/api/metrics), and scenarios simulations (/api/simulate). - Glassmorphic Web UI: A beautiful dark-theme analytics dashboard showcasing real-time price optimization, sliders to adjust market features, and interactive Chart.js visualizations.
- Docker Containerization: Portable container ready to deploy instantly.
- AWS Ready: Pre-configured for deployment to AWS App Runner or AWS ECS Fargate.
The models were evaluated using an 80/20 train-test split:
| Model Architecture |
|
Mean Absolute Error (MAE) | Training Time (sec) |
|---|---|---|---|
| Random Forest Regressor | 0.9981 | $2.87 | 3.28s |
| Neural Network (PyTorch) | 0.9952 | $5.02 | 50.28s |
| Ridge Regression | 0.9925 | $6.90 | 0.02s |
├── src/
│ ├── data_generator.py # Synthetic dataset generator
│ └── train.py # Preprocessing, feature engineering & model training
├── templates/
│ └── index.html # Dashboard UI structure
├── static/
│ ├── css/
│ │ └── styles.css # Glassmorphism dark-theme styling
│ └── js/
│ └── dashboard.js # Live slider logic & Chart.js renderer
├── app.py # Flask API backend server
├── test_api.py # Standard library automated API test client
├── Dockerfile # Multi-stage Docker image builder
├── docker-compose.yml # Container compose runner
├── requirements.txt # Python library dependencies
├── .gitignore # Excluded directories
└── AWS_DEPLOYMENT.md # Guide for pushing to Amazon ECR/ECS/App Runner
- Python 3.10+
- Git
-
Clone the Repository:
git clone https://github.com/MithraKL/dynamic-pricing-model.git cd dynamic-pricing-model -
Create and Activate Virtual Environment:
# Windows python -m venv venv .\venv\Scripts\Activate.ps1 # Mac/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Train Models: Generates synthetic dataset and exports preprocessors and model weights:
python src/train.py
- Launch the Flask application:
python app.py
- Open your browser and navigate to: 👉 http://127.0.0.1:5000
If you have Docker Desktop installed, run:
docker-compose up --buildThe server will start listening at http://127.0.0.1:5000.
To verify backend API endpoints (/api/predict, /api/metrics, /api/simulate) match validation criteria, run the test script while Flask is active:
python test_api.pyFor detailed configurations on how to push the Docker image to Amazon ECR and launch it on ECS Fargate or AWS App Runner, refer to the AWS_DEPLOYMENT.md file.
This project is licensed under the MIT License - see the LICENSE file for details.