Predicting customer churn for a fictional telecom company using machine-learning techniques.
Source: IBM Sample Data Sets
Shape: 7,043 customers × 21 features
Target: Churn – whether the customer left within the last month (Yes/No)
| Model | Accuracy | Notes |
|---|---|---|
| Random Forest | 0.7913 | Baseline with default settings |
| XGBoost | 0.7970 | Fast, good out-of-the-box |
| LightGBM | 0.8062 | Slightly better than XGBoost |
| ExtraTrees (tuned) | 0.8148 | Best score after hyper-parameter search |
- Numeric:
tenure,MonthlyCharges,TotalCharges→StandardScaler
- Categorical:
- 16 binary & multi-class columns →
OneHotEncoder(sparse=False)
- 16 binary & multi-class columns →
- Extras:
TotalChargesblanks → imputed to0Churn→ encoded to0/1
Algorithm: RandomizedSearchCV (10 iter × 5-fold CV)
Estimator: ExtraTreesClassifier
Best params:
{'n_estimators': 50,
'min_samples_split': 5,
'min_samples_leaf': 4,
'max_features': 'log2'}| Feature | Importance |
|---|---|
| Contract | 0.2026 |
| tenure | 0.1194 |
- Clone the repo
git clone https://github.com/Mawuenaa/telco-churn-ml.git cd telco-churn-ml
- Create & activate a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # macOS / Linux venv\Scripts\activate # Windows
- Install dependencies
pip install --upgrade pip pip install -r requirements.txt
- Launch Jupyter
jupyter notebook notebooks/Telco_Churn_Prediction.ipynb
telco-churn-ml/
│
├── data/
│ └── WA_Fn-UseC_-Telco-Customer-Churn.csv # original dataset
│
├── notebooks/
│ └── Telco_Churn_Prediction.ipynb # full end-to-end pipeline
│
├── README.md
├── requirements.txt
└── .gitignore # keeps data/ out of repo (optional)The notebook is self-contained:
| Step | Description |
|---|---|
| 1 | Loads & cleans the data |
| 2 | Trains 3 baseline models (RF, XGB, LGBM) |
| 3 | Performs randomized hyper-parameter search on ExtraTrees |
| 4 | Evaluates the tuned model |
| 5 | Lists feature importances |
No extra scripts needed—just run the notebook cells sequentially.
- Fork the repository
- Create a feature branch (git checkout -b feature/amazing-idea)
- Commit your changes (git commit -m 'Add amazing idea')
- Push to the branch (git push origin feature/amazing-idea)
- Open a Pull Request