Skip to content

ssarimm/churn_prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Customer Churn Prediction Project

📋 Overview

This machine learning project predicts customer churn using a Random Forest Classifier.
The goal is to identify customers who are likely to leave based on behavioral and demographic data.


📁 Project Structure

churn_prediction/
│
├── data/                # Dataset files (ignored in repo)
│   └── generate_data.py  # Script to generate sample data
│
├── models/              # Trained model files (ignored in repo)
│
├── notebooks/           # Jupyter notebooks for analysis
│   └── churn_analysis.ipynb
│
├── src/                 # Source code modules
│   ├── data_preprocessing.py
│   ├── model_training.py
│   ├── utils.py
│   └── __init__.py
│
├── main.py              # Main execution script
├── predictions.csv      # Sample predictions output
├── requirements.txt     # Python dependencies
└── README.md

⚙️ Installation

Make sure you have Python 3.8+ installed.
Then install all dependencies:

pip install -r requirements.txt

🚀 Usage

To run the full prediction pipeline:

python main.py

Or train and test the model manually:

python src/model_training.py
python main.py   # Generates predictions.csv

📄 Files Description

File Description
data_preprocessing.py Handles data cleaning and encoding
model_training.py Trains and evaluates the Random Forest model
utils.py Utility functions for predictions
main.py Runs the full churn prediction pipeline

📊 Results

Model: RandomForestClassifier (n_estimators=100, max_depth=15)

Evaluation on Test Set:

  • Accuracy: 0.912
  • Precision: 0.89
  • Recall: 0.87
  • F1-score: 0.88
  • ROC-AUC: 0.94

You can reproduce these results using:

python src/model_training.py

The predictions are saved to:

predictions.csv

📦 Output

The output file predictions.csv contains churn probabilities for each customer.
Example:

Customer_ID Churn_Probability
1001 0.12
1002 0.84
1003 0.45

🧩 Data & Model Files

The dataset (customer_churn.csv) and trained model (churn_model.pkl) are not included in this repository to keep it lightweight.

You can generate them yourself by following these steps:

  1. Generate synthetic data

    python data/generate_data.py

    This creates data/customer_churn.csv.

  2. Train the model

    python src/model_training.py

    This saves the trained model as models/churn_model.pkl.

  3. Run predictions

    python main.py

    This creates a predictions.csv file with churn probabilities.


🧾 License

This project is open-source and available under the MIT License.


👨‍💻 Author

Sarim ShahGitHub: @ssarimm

About

This project focuses on predicting customer churn using machine learning. Customer churn refers to when customers stop using a company’s product or service.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages