This project demonstrates a complete end-to-end data analytics and machine learning workflow. It includes data processing, exploratory analysis, relational SQL querying, star schema modeling, a churn-prediction ML pipeline, and a Django REST API for serving predictions.
This architecture diagram outlines the end-to-end pipeline from data extraction to predictive modeling and dashboard visualization. (Note: the editable Excalidraw file is located at ml/artifacts/Customer-Behavior-Analysis-Power-BI— System Architecture.excalidraw).
customer_behavior_analysis/
├── .github/
│ └── workflows/ # CI/CD Automation
│ ├── python-test.yml # Python Testing CI
│ └── dependency-review.yml # Dependency Review (PRs)
├── api/ # Django REST API
│ ├── manage.py
│ ├── customer_behavior_django_api/
│ └── ml_models/ # ML endpoints & models
├── data/ # Raw and Processed Datasets
│ ├── raw/ # Original, unprocessed dataset
│ ├── processed/ # Star Schema (Fact/Dim tables)
│ └── data-dictionary.md # Documentation of dataset columns
├── ml/ # Churn prediction model (Random Forest)
│ ├── train_churn.py
│ └── api_churn.py
├── notebooks/ # Jupyter Analysis & EDA
│ ├── eda-analysis.ipynb
│ └── analysis.py
├── powerbi/ # Visualization & Dashboarding
│ ├── customer-behavior-dashboard.pbix # Main Power BI Report
│ ├── DAX-Measures.md # Documentation of analytical logic
│ └── dashboard.png
├── scripts/ # Utility Scripts (Data Diversification)
│ └── data-diversification.py
├── sql/ # SQL Scripts (Analysis & Joins)
│ ├── analytical-queries/
│ └── relational-schema/
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md # This file
└── requirements.txt # Versioned project dependencies
data/raw/) is processed via scripts/data-diversification.py into a Star Schema.DIM_Customers, DIM_Products) and Fact (FACT_Sales) tables are created in data/processed/.sql/relational-schema/, with reusable reporting queries in sql/analytical-queries/.powerbi/customer-behavior-dashboard.pbix.Churn prediction is trained and served from ml/:
ml/train_churn.py — trains the Random Forest churn model, with MLflow tracking.ml/api_churn.py — exposes the trained model for inference, wired into the Django API’s /api/churn/ endpoint.Confusion Matrix

Feature Importance

ROC Curve

Serve predictions via Django REST Framework.
/api/segment/ : Customer segmentation/api/predict/ : Purchase prediction/api/churn/ : Churn prediction/api/recommend/ : Product recommendationpython-test.yml).dependency-review.yml).Clone the Repository
git clone https://github.com/toxicbishop/Customer-Behavior-Analysis-Power-BI.git
cd Customer-Behavior-Analysis-Power-BI
Environment Setup
python -m venv .venv
# On Windows: .venv\Scripts\activate
# On Unix: source .venv/bin/activate
pip install -r requirements.txt
Running the API
cd api
python manage.py migrate
python manage.py runserver
Training the Churn Model
python ml/train_churn.py
This project is licensed under the MIT License - see the LICENSE file for details.