This project focuses on predicting customer churn in a banking environment using Machine Learning techniques. The goal of the project was to analyze customer behavior, identify patterns related to churn, and build predictive models capable of identifying customers who are likely to leave the bank.
The dataset used in this project is the Churn Modelling Dataset, which contains information about bank customers such as demographic data, account information, banking activity, and churn status.
1. Data Loading and Initial Exploration
Objective
The purpose of this stage was to load the dataset, understand its structure, and identify potential data quality issues before beginning the analysis.
Dataset Description
The project used the Churn Modelling Dataset, which contains customer information from a banking environment. The dataset focuses on predicting customer churn, meaning whether a customer is likely to leave the bank.
The dataset includes approximately 10,000 customer records and multiple customer-related features.
Main Feature Types
The dataset contains several categories of features:
Demographic Features
Geography
Gender
Age
Financial Features
Credit Score
Balance
Estimated Salary
Banking Activity Features
Number of Products
Tenure
Active Membership Status
Credit Card Ownership
Target Variable
Exited
1 = customer churned
0 = customer remained
This established the problem as a supervised binary classification task.
Key Findings
The dataset was relatively clean and did not contain significant missing values.
Most features were numerical, while categorical features such as Geography and Gender required encoding later in the preprocessing stage.
The data appeared suitable for Machine Learning modeling without major cleaning requirements.
2. Exploratory Data Analysis (EDA)
Objective
The goal of the EDA phase was to understand customer behavior patterns and identify relationships between customer attributes and churn.
Analysis Performed and Findings
Customer Churn Distribution
The churn distribution was analyzed in order to understand whether the dataset was balanced.
Findings
The dataset was imbalanced, with significantly more customers remaining in the bank than customers who churned.
This insight became important later during model evaluation because accuracy alone could become misleading.
Geography vs Churn Analysis
The relationship between customer location and churn behavior was examined.
Findings
Customers from Germany demonstrated a noticeably higher churn rate compared to customers from France and Spain.
This suggested that geographic location may strongly influence customer retention behavior.
---
Gender vs Churn Analysis
The project compared churn behavior between male and female customers.
Findings
Female customers showed a slightly higher churn rate compared to male customers.
Although the difference was not extreme, gender still appeared to contribute to customer behavior patterns.
Age Distribution Analysis
Customer age distributions were analyzed using histograms and boxplots.
Findings
Older customers were significantly more likely to churn.
The graphs clearly showed that churned customers generally belonged to higher age ranges compared to non-churned customers.
This became one of the strongest indicators of churn.
Credit Score Analysis
The relationship between credit score and churn was analyzed.
Findings
The relationship between credit score and churn was relatively weak.
Although some churned customers had lower credit scores, the difference between groups was not very large.
This suggested that credit score alone is not a strong predictor of churn.
image
---
Tenure Analysis
The effect of customer seniority in the bank was examined.
Findings
Tenure did not show a strong direct relationship with churn.
Customers with both low and high tenure appeared in both churn classes.
This indicated that tenure alone was insufficient for predicting customer behavior.
Active Membership Analysis
The project analyzed whether active customers were less likely to churn.
This suggested that customer engagement is strongly connected to retention.
Active membership became one of the most important business indicators in the project.
Credit Score Analysis
The relationship between customer credit score and churn behavior was analyzed by comparing the score distributions of churned and non-churned customers.
Findings
The graph showed a strong overlap between both groups, with most customers concentrated in similar credit score ranges.
This indicates that credit score alone does not have a clear direct relationship with churn behavior.
However, when combined with behavioral and financial features, credit score may still contribute valuable predictive information for Machine Learning models.
3. Data Preprocessing and Baseline Definition
Objective
The preprocessing stage prepared the dataset for Machine Learning models and established the project's baseline performance.
Train-Test Split
The dataset was divided into:
80% Training Data
20% Testing Data
This means:
Approximately 8,000 rows were used for training
Approximately 2,000 rows were used for testing
The split ensured that the models were evaluated on unseen data.
Actions Performed
Encoding Categorical Variables
Categorical variables such as:
Geography
Gender
were converted into numerical values using encoding methods.
Feature Scaling
Numerical variables were standardized when necessary in order to prevent variables with larger scales from dominating the models.
Baseline Definition
A baseline model was established before building advanced Machine Learning models.
What is a Baseline?
A baseline represents the minimum expected performance level.
Its purpose is to provide a simple reference point that all advanced models must outperform.
In this project, the baseline helped evaluate whether the Machine Learning models were truly learning meaningful customer behavior patterns.
Key Findings
The preprocessing stage ensured that:
All features could be properly interpreted by the models
Model evaluation remained objective
Advanced models could be compared fairly against the baseline
Decisions Made
It was decided to:
Use encoded categorical features in all models
Apply consistent preprocessing across experiments
Compare every advanced model against the baseline performance
The baseline model achieved the following results:
Although regression modeling provided useful insights, the project concluded that churn prediction is fundamentally a classification problem.
Therefore, the next stage focused on classification models.
--- Model Comparison ---
Model RMSE R2
0 Linear Regression (Engineered) 0.354927 0.202134
1 Decision Tree 0.378814 0.091126
2 Random Forest 0.362629 0.167130
6. Regression Modeling
Objective
The assignment included experimentation with regression models in order to compare predictive approaches.
Models Used
The project experimented with:
Linear Regression
Purpose
The regression phase was mainly exploratory and educational, helping compare regression outputs with classification-based approaches.
Key Findings
Regression models were less suitable for this problem because:
The target variable is binary
Churn prediction is fundamentally a classification problem
This reinforced the need to focus on classification algorithms.
Decisions Made
The project transitioned toward classification models as the primary predictive approach.
7. Classification Modeling
Objective
The goal of this stage was to transform the problem into a binary classification task and predict whether a customer would churn or remain with the bank.
Classification Definition
The dataset was divided into two classes:
Class 0 → Customer stayed in the bank
Class 1 → Customer churned and left the bank
This created a supervised binary classification problem.
Models Evaluated
Several classification models were trained and compared:
Logistic Regression
K-Nearest Neighbors (KNN)
Random Forest Classifier
Evaluation Metrics
The models were evaluated using:
Accuracy
Precision
Recall
F1-Score
Confusion Matrix
Key Findings
The classification stage demonstrated clear differences between the models.
The evaluation showed that churn prediction requires balancing:
identifying churned customers correctly
minimizing unnecessary false alarms
This made Recall and F1-Score especially important metrics.
Add Relevant Figures Here
image
8. Model Evaluation and Comparison
Objective
The purpose of this stage was to compare all classification models and identify the strongest predictive solution.
Models Compared
The project compared:
Logistic Regression
K-Nearest Neighbors (KNN)
Random Forest Classifier
Evaluation Metrics
The models were evaluated using:
Recall
F1-Score
Accuracy
Precision
Logistic Regression Results
Performance
Recall: High
F1-Score: Moderate
Interpretation
The Logistic Regression model successfully identified many churned customers.
This means:
The model achieved relatively strong Recall.
However:
It also generated many False Positives.
Precision was weaker.
Business Meaning:
The model was aggressive in predicting churn.
While it reduced the risk of missing churned customers, it would also create many unnecessary retention interventions.
KNN Results
Performance
Lowest Recall
Lowest F1-Score
Interpretation
The KNN model struggled to generalize effectively.
It failed to identify churned customers consistently and produced weak overall performance.
Business Meaning:
The model was not reliable enough for churn prediction because it missed too many actual churn cases.
Random Forest Results
Performance
Accuracy: ~87%
Recall: ~45%
F1-Score: ~0.57
Interpretation
The Random Forest model achieved the strongest balance between:
Recall
Precision
Accuracy
F1-Score
Unlike Logistic Regression:
it reduced unnecessary False Positives
while still identifying a significant portion of churned customers
Unlike KNN:
it generalized much better
and produced stable results across all evaluation metrics
Business Meaning:
The model provided the best balance between:
detecting churn risk
minimizing operational noise
maintaining reliable prediction quality
Why Random Forest Was Selected
The Random Forest model was selected as the final model because:
It achieved the highest overall Accuracy (~87%)
It achieved the strongest F1-Score (~0.57)
It maintained solid Recall performance
It reduced False Positives compared to Logistic Regression
It produced the most balanced and stable results overall
Although Logistic Regression achieved higher Recall, its lower Precision created too many false churn predictions.
The Random Forest model achieved the best overall tradeoff between:
identifying churned customers
maintaining prediction reliability
reducing unnecessary business interventions
Therefore:
Random Forest was considered the strongest and most business-effective model.
Final Conclusions
This project demonstrated a complete Machine Learning workflow for customer churn prediction.
The analysis showed that customer churn is strongly influenced by:
age
customer activity
geography
product usage
financial engagement
Several Machine Learning models were evaluated.
The final selected model was:
Random Forest Classifier
because it achieved the best balance between:
Recall
Precision
Accuracy
F1-Score
The project also highlighted the importance of selecting evaluation metrics according to business goals rather than relying solely on accuracy.