This project predicts customer churn using a Random Forest Classifier. Customer churn refers to the likelihood of a customer leaving a service provider. The prediction model utilizes various customer attributes such as demographics, subscription details, and service usage.
A web application built with Flask allows users to input customer details and receive predictions along with the probability of churn.
- Machine Learning: Random Forest Classifier for churn prediction.
- Data Preprocessing: Encoders and scalers for categorical and numerical data transformation.
- Web Application: User-friendly interface for predictions.
- Scalable Design: Easily adaptable to new features.
The model uses the following features for prediction:
genderSeniorCitizenPartnerDependents
PhoneServiceMultipleLinesInternetServiceOnlineSecurityOnlineBackupDeviceProtectionTechSupportStreamingTVStreamingMovies
ContractPaperlessBillingPaymentMethod
tenureMonthlyChargesTotalCharges
- Required Libraries:
- Flask
- pandas
- scikit-learn
- pickle
- matplotlib
- numpy
git clone python app.pyOpen your browser and go to:http://127.0.0.1:5000/
|__ data
├── app.py
├── model/
│ ├── best_model.pkl
│ ├── encoder.pkl
│ ├── scaler.pkl
├── templates/
│ └── index.html
── README.md
- Input Data: User provides customer details in a web form.
- Data Preprocessing:
- Encodes categorical features.
- Scales numerical features (
tenure,MonthlyCharges,TotalCharges).
- Prediction:
- Outputs whether the customer is likely to Churn or Not Churn.
- Provides the probability of churn.
- Output: Results are displayed on the web interface.
| Feature | Example Value |
|---|---|
gender |
Male |
SeniorCitizen |
0 (No) |
Partner |
Yes |
Dependents |
No |
tenure |
24 |
PhoneService |
Yes |
MultipleLines |
No |
InternetService |
Fiber optic |
OnlineSecurity |
No |
OnlineBackup |
Yes |
DeviceProtection |
No |
TechSupport |
No |
StreamingTV |
Yes |
StreamingMovies |
Yes |
Contract |
Two year |
PaperlessBilling |
No |
PaymentMethod |
Credit card |
MonthlyCharges |
85.75 |
TotalCharges |
2075.5 |
- Add functionality to train models directly through the app.
- Support additional machine learning models for comparison.
- Deploy the app on cloud platforms like AWS, GCP, or Heroku.
- Improve the user interface for better usability.
