- 🚀 Live Demo: Click here to use the App
- ✍️ Medium Article: My Journey Building a Production-Ready ML App
In the retail industry, "one-size-fits-all" pricing strategies waste margin and fail to prevent churn. This project is a full-stack Machine Learning solution designed to automatically segment customers and recommend targeted discount strategies based on purchasing behavior.
Instead of a static analysis, this project features a live web application that allows marketing teams to:
- Simulate single-user scenarios.
- Batch process thousands of transaction rows via Excel upload.
- Download actionable reports with discount recommendations.
This project moves beyond simple notebooks by implementing a modular, production-oriented workflow:
- ETL Pipeline: Ingests raw Excel transaction data, cleans it, and loads it into a SQLite database for persistent storage.
- Feature Engineering: transform raw data into RFM Metrics (Recency, Frequency, Monetary).
- Machine Learning: Uses K-Means Clustering (Unsupervised Learning) to identify distinct customer personas.
- Unit Testing: Implements Pytest to ensure data cleaning logic handles edge cases (e.g., negative quantities/returns) correctly.
- Deployment: Hosted on Streamlit Cloud with a CI/CD pipeline via GitHub.
The unsupervised model identified 3 distinct customer groups:
| Cluster | Profile | Behavior | Recommendation |
|---|---|---|---|
| 0 | At-Risk | High Recency (hasn't bought in a long time), Low Frequency. | Targeted 15% Discount to prevent churn. |
| 1 | Regular | Average spending and frequency patterns. | Standard Marketing engagement. |
| 2 | VIP | High Frequency and High Monetary spend. | No Discount. Upsell premium products. |
To run this project on your local machine, follow these steps:
1. Clone the Repository
git clone [https://github.com/jacknayem/dynamic-pricing-optimizer.git](https://github.com/jacknayem/dynamic-pricing-optimizer.git)
cd dynamic-pricing-optimizer