# E-commerce Churn (Ghana)
Data → RFM → Logistic Regression → Elasticsearch/Kibana
Predict which customers are at risk of **churn** (no purchase in the last **45 days**) and visualize activity with **Elasticsearch + Kibana**. The notebook generates **synthetic, Ghana‑flavoured** data, builds **RFM** features, trains a **Logistic Regression** model, and ships event data to Elasticsearch for dashboards.
---
## Tech Stack
- **Python**: `pandas`, `numpy`, `scikit-learn`, `matplotlib`, `seaborn`, `plotly`, `faker`, `duckdb` (optional)
- **Model**: Logistic Regression (with `StandardScaler` in a pipeline)
- **Big-data demo**: Elasticsearch 8.x + Kibana 8.x (via Docker)
- **Notebook**: `E-commerce_insights_data_analysis.ipynb`
---
## Repository Structure
```
.
├─ E-commerce_insights_data_analysis.ipynb # end-to-end workflow (run top → bottom)
├─ docker-compose.yml # Elasticsearch + Kibana (Docker)
├─ requirements.txt # Python dependencies (pinned)
├─ data/ # generated CSVs (auto-created by notebook)
└─ docs/
├─ kibana_dashboard.png # add after you build dashboards
├─ roc_pr_curves.png # add after you plot metrics
└─ lift_table.png # add after you export lift table
```
---
## Prerequisites
- Python **3.11+**
- Docker Desktop (or Docker Engine) running
- Windows users: PowerShell; macOS/Linux: Terminal
---
## Quickstart
### 1) Create & Activate a Python Environment
```bash
# create project folder and enter
mkdir ecommerce-churn-ghana && cd ecommerce-churn-ghana
# create venv
python -m venv .venv
# activate it
# Windows (PowerShell):
. .venv/Scripts/Activate
# macOS/Linux:
source .venv/bin/activate
```
### 2) Add Dependencies
Create a file named `requirements.txt` with the following content:
```txt
jupyterlab==4.2.5
pandas==2.2.2
numpy==1.26.4
scikit-learn==1.5.2
matplotlib==3.9.0
seaborn==0.13.2
plotly==5.24.1
faker …