The goal of this project is to predict the likelihood of a Telco customer churning using Machine Learning techniques with Python and TensorFlow. This allows the company to implement retention strategies and reduce customer loss.
Telco_Churn/
ββ data/
β ββ raw/ # Original dataset downloaded from Kaggle
β ββ processed/ # Cleaned and transformed data
ββ notebooks/
β ββ EDA.ipynb # Initial exploratory data analysis
ββ src/
β ββ preprocessing.py # Data cleaning and preprocessing functions
β ββ model.py # Model definition and training
β ββ evaluate.py # Model evaluation and metrics
β ββ visualize.py # Visualization functions (Precision-Recall curve)
ββ outputs/
β ββ figures/ # Generated plots
β ββ models/ # Saved trained models (.keras)
ββ requirements.txt # Project dependencies
ββ README.md # Project documentation
ββ run.py # Main script to execute the full pipeline
- Python 3.x
- pandas, numpy
- scikit-learn
- TensorFlow
- matplotlib
-
Data Loading & Preprocessing
- Load raw dataset and clean missing values.
- Convert categorical variables using one-hot encoding.
- Scale numerical features with StandardScaler.
-
Model Training
- Neural network built with TensorFlow/Keras.
- Dense layers with ReLU activation and Dropout for regularization.
- Binary classification using sigmoid output.
-
Evaluation
- Compute Precision, Recall, F1-score and ROC-AUC.
- Calculate the best threshold to maximize F1-score.
-
Visualization
- Precision-Recall curve is saved in
outputs/figures/. - Threshold that maximizes F1 is highlighted on the plot.
- Precision-Recall curve is saved in
-
Outputs
- Trained model saved in
outputs/models/. - Predictions can be exported for further analysis or Power BI dashboards.
- Trained model saved in
After training, example results:
- Accuracy: 0.76
- ROC-AUC: 0.82
- Best F1 Threshold: 0.54
- Class 1 (Churners): Precision 0.53, Recall 0.74, F1 0.62
Note: Metrics are computed on a hold-out test set. The threshold is optimized for business use-case to capture most churners while controlling false positives.
- Clone the repository:
git clone https://github.com/quantumRizo/Telco_Churn.git