An industry-grade data science project that simulates a real-world subscription-based e-commerce business and builds three production-relevant machine learning systems:
- π― Customer Segmentation (Unsupervised Learning)
β οΈ Churn Prediction (Classification)- π° Next-Month Spend Forecasting (Regression)
Modern e-commerce platforms generate large volumes of customer behavioral and transactional data. However, without structured analytics, businesses fail to:
- Identify high-value customers
- Prevent customer churn
- Forecast revenue accurately
This project builds a data-driven decision system that enables businesses to:
- Segment customers intelligently
- Predict churn risk proactively
- Forecast revenue at a granular level
- Identify distinct customer groups
- Enable targeted marketing strategies
- Improve campaign efficiency
- Predict probability of customer churn
- Enable early retention intervention
- Predict next-month customer spending
- Support revenue planning and personalization
- π₯ Customers: 5,000
- π Transactions: ~40,000
- π Simulated over multiple months
- Age (18β70)
- Income ($5K β $150K)
- Country (US 60%, UK 40%)
- Tenure (1β60 months)
- Visits per month (Poisson distributed)
- Engagement intensity
- Total orders
- Total spend
- Average order value (AOV)
- Discount usage patterns
- Average monthly visits: 5.8 visits/user
- Average order value: $72.4
- Average spend per customer: $1,180
- High-income segment contributes ~48% of total revenue
- Income distribution is right-skewed
- Engagement strongly correlates with spending
- Low-activity users show early signs of churn
- Total Spend
- Total Orders
- Avg Order Value
- Visit Frequency
- Spend per visit
- Engagement ratio
- Tenure-adjusted activity
- Feature Scaling using StandardScaler
- PCA β Reduced to 2 components (~81% variance explained)
- KMeans clustering
- Elbow Method β K = 5
| Cluster | Size | Avg Spend | Avg Visits | Segment Type |
|---|---|---|---|---|
| 0 | 1,120 | $1,950 | 8.2 | High-value engaged |
| 1 | 980 | $420 | 2.1 | Low-value inactive |
| 2 | 1,050 | $1,200 | 5.4 | Mid-tier steady |
| 3 | 890 | $300 | 3.0 | Price-sensitive |
| 4 | 960 | $2,400 | 9.5 | Premium users |
- Top 20% customers generate ~55% revenue
- Low-engagement users (<3 visits/month) have 2.5x higher churn risk
- Premium segment shows highest retention
- Logistic Regression
- Random Forest β (Best)
| Metric | Logistic Regression | Random Forest |
|---|---|---|
| Accuracy | 0.78 | 0.86 |
| Precision | 0.74 | 0.83 |
| Recall | 0.69 | 0.81 |
| F1 Score | 0.71 | 0.82 |
- Low visits/month
- Low spend
- Short tenure
- High discount usage
- Users with <3 visits/month β 68% churn probability
- Users with tenure >24 months β <15% churn probability
- Linear Regression
- RMSE: $142.6
- RΒ² Score: 0.72
- Historical spend
- Visit frequency
- Avg order value
- Tenure
- Users with β₯8 visits/month spend 2.3x more
- High AOV users dominate revenue growth
Data Simulation
β
EDA & Validation
β
Feature Engineering
β
Segmentation (K-Means + PCA)
β
Churn Prediction (Random Forest)
β
Spend Forecasting (Linear Regression)
β
Business Insights
- Top 20% customers generate >50% of revenue
- Engagement is the strongest predictor of churn
- Segmentation enables targeted marketing
- Spend prediction improves revenue planning
- Built multi-model ML pipeline (unsupervised + classification + regression)
- Applied feature engineering for behavioral analytics
- Connected ML outputs to business decisions
- Learned trade-offs between model types
- Python
- Pandas / NumPy
- Matplotlib / Seaborn
- Scikit-learn
- KMeans
- PCA
- Random Forest
- Linear Regression
Customer-Analytics-Case-Study/
β
βββ CASE_STUDY_DS.ipynb
βββ README.md
- XGBoost / LightGBM models
- Time-series forecasting
- FastAPI deployment
- Model monitoring
- Cloud deployment (AWS/GCP)
Birjung Thapa
Masterβs in Data Science
University of Colorado Boulder
If you found this project useful:
β Star the repo
π’ Share with others
π€ Connect for collaboration