You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Customer Churn Prediction
Predict customer churn using machine learning on the Telco Customer Churn dataset. This project uses a Random Forest Classifier with SMOTE to handle class imbalance and identify customers who are most likely to leave a telecom service. Alternative techniques such as class_weight= 'balanced' or cost-sensitive learning should also be considered.
Project Overview
This project follows a complete machine learning workflow:
Cleaned and preprocessed the dataset
,Handled missing values
, Encoded categorical features
,Scaled numerical features
, Balanced the training data using SMOTE
,Trained a Random Forest Classifier
,Evaluated the model using multiple performance metrics
& Identified the most important features influencing customer churn
Technologies Used:
Python
,Pandas
,NumPy
,Scikit-learn
,imbalanced-learn (SMOTE)
,Matplotlib
& Seaborn
Model Performance
Overall Performance
Metric Score
Accuracy 76%
ROC AUC 0.812
Churn Class
Metric Score
Precision 0.54
Recall 0.64
F1-Score 0.59
Non-Churn Class
Metric Score
Precision 0.86
Recall 0.81
F1-Score 0.83
Results
Confusion Matrix

ROC Curve:

Feature Importance:

Key Insights
The model found that the most influential features for predicting customer churn were:
Customer tenure
,Total charges
, Monthly charges
,Contract type
& Payment method (Electronic Check)
Customers with shorter tenures, higher monthly charges, month-to-month contracts, and electronic check payments were more likely to churn.
Project Structure
Customer-Churn-Prediction/
customer_churn.py
requirements.txt
confusion_matrix.png
roc_curve.png
feature_importance.png
README.md
data/
Telco-Customer-Churn.csv
Installation:
Clone the repository.
git clone https://github.com/Acacia21-code/customer-churn-prediction.git
Move into the project directory.
cd customer-churn-prediction
Install the required packages.
pip install -r requirements.txt
Run the project.
python customer_churn.py
Dataset:
Telco Customer Churn Dataset
https://www.kaggle.com/datasets/blastchar/telco-customer-churn
Future Improvements:
Tune model hyperparameters using GridSearchCV
, Compare performance with XGBoost and Logistic Regression
, Build an interactive Streamlit web application
,Add model explainability using SHAP
& Experiment with additional feature engineering
Author:
Mbali
Aspiring Machine Learning Engineer passionate about building practical machine learning solutions and continuously learning new technologies.
About
Predicts telecom customer churn using a Random Forest classifier on the Telco Customer Churn dataset. Includes preprocessing, SMOTE for class imbalance, and evaluation via ROC AUC, confusion matrix, and feature importance.