{"id":18881544,"url":"https://github.com/azlinrusnan/bank_turnover_analysis","last_synced_at":"2025-08-15T00:35:21.217Z","repository":{"id":235799488,"uuid":"791088814","full_name":"AzlinRusnan/Bank_Turnover_Analysis","owner":"AzlinRusnan","description":"This repository offers advanced solutions for efficient data handling, processing, and analytics.","archived":false,"fork":false,"pushed_at":"2024-05-10T07:35:00.000Z","size":1336,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T08:37:50.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AzlinRusnan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T04:32:34.000Z","updated_at":"2024-06-05T01:44:53.000Z","dependencies_parsed_at":"2024-11-08T06:49:56.895Z","dependency_job_id":"2ae9d0d1-f213-43a4-afc7-8b6ee91b4f7a","html_url":"https://github.com/AzlinRusnan/Bank_Turnover_Analysis","commit_stats":null,"previous_names":["azlinrusnan/data_management","azlinrusnan/bank_turnover_analysis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AzlinRusnan/Bank_Turnover_Analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzlinRusnan%2FBank_Turnover_Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzlinRusnan%2FBank_Turnover_Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzlinRusnan%2FBank_Turnover_Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzlinRusnan%2FBank_Turnover_Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AzlinRusnan","download_url":"https://codeload.github.com/AzlinRusnan/Bank_Turnover_Analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzlinRusnan%2FBank_Turnover_Analysis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260546274,"owners_count":23025908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T06:49:55.107Z","updated_at":"2025-06-18T11:40:15.619Z","avatar_url":"https://github.com/AzlinRusnan.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cdiv align=\"center\"\u003eBANK TURNOVER ANALYSIS\u003c/div\u003e\n![Intro](https://github.com/Pradnya1208/Telecom-Customer-Churn-prediction/blob/main/output/customer%20churn.jpeg?raw=true)\n\n## What is Customer Churn 🤔?\n**Click on the video to watch📺**\n\n[![Watch the video](https://img.youtube.com/vi/InOB1wXEkC8/0.jpg)](https://www.youtube.com/watch?v=InOB1wXEkC8)\n\n## Project Overview:\n\nThis project focuses on analyzing bank turnover to identify key factors contributing to customer churn in the banking sector. By leveraging data-driven insights, we aim to propose strategies to improve customer retention and enhance service delivery.\n\n## Objectives:\n\n- **Understand Customer Behavior**: Analyze historical data to understand why customers leave the bank.\n- **Predictive Modeling**: Develop models to predict potential churn to enable proactive retention strategies.\n- **Actionable Insights**: Provide actionable recommendations based on the analysis to reduce turnover rates.\n\n## Dataset 📖:\n The source of the data is from [Bank Customer Churn](https://www.kaggle.com/datasets/radheshyamkollipara/bank-customer-churn/data)\n\n## Data Description:\n\nThe dataset used in this analysis contains the following key attributes:\n\n- RowNumber : Identification for each row.\n- CustomerId, Surname: Identifiers and names, generally not useful for prediction.\n- CreditScore, Geography, Gender, Age: Demographic information.\n- Tenure, Balance, NumOfProducts, HasCrCard, IsActiveMember, EstimatedSalary: Financial and account-related details.\n- Exited: This is the target variable indicating whether a customer has churned (1) or not (0).\n- Complain, Satisfaction Score, Card Type, Point Earned: Additional customer satisfaction and engagement metrics.\n\n## Implementation:\n\n**Libraries:** sklearn, Matplotlib, pandas, seaborn, and NumPy\n\n## Data Cleaning\n\n### 1. Checking Data Information\n\u003e![Data Information](images/datainfo.png)\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eThe dataset contains 10,000 records across 18 columns, which include 15 numerical and 3 categorical columns.\n\n### 2. Checking the Total Number of Missing Values\n\u003e\n\u003e![Total Number of Missing Values](images/missingvalues.png)\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eAs indicated by the table, there are no missing values; therefore, data imputation is not necessary.\n\n### 3. Checking for Duplicate Values\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eThere is 0 duplicate row in the dataset\n\n### 4. Dropping Irrelevant Columns\n\u003e![Dropping Irrelevant Columns](images/drop1.png)\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eWe dropping [\"RowNumber\",\"CustomerId\",\"Surname\"] as they did not give significant contribution to the analysis\n\n### 5. Renaming Values in Exited Column\n\u003e![Renaming Values in Exited Column](images/onezero.png)  to  ![Renaming Values in Exited Column](images/yesno.png)\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eFor this report, since we need to check and compare other variables with the Exited column, we decided to change the Exited column from binary values (0, 1) to (No, Yes) to enhance visibility during the analysis. Additionally, we will retain the four columns with binary numbers as we believe they will be beneficial for later statistical analysis.\n\n\n## Exploratory Data Analysis 📊:\n\n### 1. Displaying Customer Turnover Distribution\n\u003e![Customer Turnover Distribution](images/Distribution.png)\n\u003eThe dataset shows a significant difference between the number of customers who have left the bank (\"Yes\") and those who have stayed (\"No\").\n\n### 2. Displaying Customer Turnover by Gender\n\u003e![Customer Turnover by Gender](images/Gender.png)\n\u003e**Insight:**\n\u003e\n\u003eAccording to the Gender bar graph above, female customer leading the percentage of turnover (11.4%) from the bank compared to male(9.0%).\n\u003e\n\u003e**Recommendation:**\n\u003e\n\u003e1. **Customer Research:** Conduct surveys, focus groups, and interviews with female customers to understand their specific concerns, preferences, and needs. This \u003eresearch can reveal insights into why they may be more likely to turn from bank.\n\u003e\n\u003e2. **Monitoring and Feedback:** Regularly monitor the effectiveness of these strategies through ongoing feedback mechanisms and adjust them as necessary to ensure they \u003econtinue to meet the needs of female customers effectively\n\n### 3. Displaying Customer Turnover by Number of Product\n\u003e![Customer Turnover by Number of Product](images/Product.png)\n\u003e**Note:**\n\u003e\n\u003eBanks offer a wide range of products and services to meet the financial needs of their customers, ranging from basic banking services to more complex financial \u003esolutions. For example here's a list of products from Maybank (https://www.maybank.com/en/products-and-services.page):\n\u003e\n\u003e1. Wealth Management\n\u003e2. Insurance \u0026 Takaful \n\u003e3. Consume and Digital Solutions\n\u003e4. Etc..\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eThe majority of customers hold either one or two products, while fewer customers have more than two products.\n\u003eThe highest turnover occurs among customers with only one product.\n\u003e\n\u003e**Recommendation:**\n\u003e\n\u003e1. **Customer Research:** Conduct surveys, focus groups, and interviews with female customers to understand their specific concerns, preferences, and needs. This \u003eresearch can reveal insights into why they may be more likely to turn from bank.\n\u003e\n\u003e2. **Monitoring and Feedback:** Regularly monitor the effectiveness of these strategies through ongoing feedback mechanisms and adjust them as necessary to ensure they \u003econtinue to meet the needs of female customers effectively.\n\n### 4. Displaying Customer Turnover Based on Active Status (Active vs. Non-Active)\n\u003e![Customer Turnover by Active Member or Not](images/Isactivemember.png)\n\u003e**Insight:**\n\u003e\n\u003e1. IsActiveMember: Indicates active membership status (1 = Active, 0 = Inactive).\n\u003e2. Active members show a significantly lower turnover rate compared to inactive members, highlighting the importance of engagement in customer retention strategies.\n\u003e\n\u003e**Recommendation:**\n\u003e\n\u003eIt is a loss if a bank loses its customer. Below are the few suggestions that can keep customer running away from a bank:\n\n\u003e1. **Loyalty Programs:** Implementing loyalty programs that reward customers for their business can increase retention. Rewards could be in the form of better rates, \u003elower fees, or even non-banking perks.\n\u003e2. **Community Engagement:** Banks that actively engage with their community, such as sponsoring local events or supporting local businesses, can build goodwill and \u003estrong local customer base.\n\n### 5. Displaying Customer Turnover by Satisfaction Score\n\u003e![Customer Turnover by Satisfaction Score](images/SatisfactionScore.png)\n\u003e **Note:**\n\u003e\n\u003eThe visualization for \"Customer Turnover by Satisfaction Score\" shows the distribution and impact of satisfaction scores on customer churn. The percentages \u003eindicate how each satisfaction score segment contributes to the overall customer churn and retention with score 5 is the perfect score and 1 is the lowest score.\n\n\u003e**Insights:**\n\u003e\n\u003eSatisfaction score of 2 appear to have higher churn rates, suggesting that less satisfied customers are more likely to leave. This relationship can guide \u003estrategies to improve customer retention by focusing on enhancing satisfaction levels.\n\n### 6. Visualizing Customer Turnover by Balance.\n\u003e![Customer Turnover by Balance](images/Balance.png)\n\u003e**Insights:**\n\u003e\n\u003eOver 3,000 customers have a zero account balance. These customers are more likely to deactivate their accounts. When excluding zero values, the balance \u003edistribution approximates a normal distribution.\n\u003e\n\u003e**Recommendations:**\n\u003e\n\u003e1. For customers with low or zero balances, strategies to engage them might be developed to prevent account dormancy and potentially convert them into more active, \u003eprofitable customers.\n\u003e\n\u003e2. Analyzing the needs of different segments might reveal opportunities for new financial products or services, especially targeted at high-balance customers who \u003eshow a higher propensity to turnover.\n\n### 7. Visualizing Customer Turnover by Age.\n\u003e![Customer Turnover by Age](images/Age.png)\n\u003e**Insights:**\n\u003e\n\u003e1. Customers who exited are typically older than those who stayed. The distribution for those who exited is skewed towards older ages, while the distribution for \u003ethose who stayed is more concentrated in the younger age range.\n\u003e\n\u003e2. Notably, the peak for customers who exited (Yes) is much higher around ages 45 to 60, suggesting this age group is at higher risk of churning.\n\u003e\n\u003e3. The median age of customers who exited is higher than those who stayed. This is evident from the position of the median line in each box.\n\u003e\n\u003e4. Customers who stayed have a narrower interquartile range (IQR), mostly concentrated between the ages of 30 and 40. In contrast, the age range for those who \u003eexited is broader, with a lower quartile near 40 and an upper quartile extending to around 55.\n\n### 8. Correlation Matrix\n\u003e![Correlation Matrix](images/CorrMatrix.png)\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eThe correlation matrix above highlights several important relationships:\n\n\u003e1. **Age**: Shows a moderate positive correlation with Exited, suggesting that older customers are more likely to exit.\n\u003e   \n\u003e2. **IsActiveMember**: Has a negative correlation with Exited, confirming that active members are less likely to leave.\n\u003e   \n\u003e3. **Balance**: Has a small positive correlation, indicating a slight tendency for customers with higher balances to exit, which might be counterintuitive and \u003ewarrants further investigation.\n\u003e   \n\u003e4. **NumOfProducts**: Interestingly, there's a negative correlation here; customers with more products are slightly less likely to exit, which might suggest that \u003ediversified services could help in retention.\n\n## Machine Learning 🦾:\n\n### 1. Encoding Categorical Columns and Splitting the Dataset\n``` Python\n# Encoding categorical columns\nlabel_encoder = LabelEncoder()\ncategorical_cols = ['Geography', 'Gender', 'Card Type']\nfor col in categorical_cols:\n    df[col] = label_encoder.fit_transform(df[col])\n\n# Splitting the dataset into training and testing sets\nX = df.drop('Exited', axis=1)\ny = df['Exited']\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)\n\n# Checking the shapes of the splits\nX_train.shape, X_test.shape, y_train.shape, y_test.shape\n```\n\u003e**Insight:**\n\u003e\n\u003e1. **Encoding Categorical Variables:** Convert categorical variables like Geography, Gender, and Card Type into a format that can be used by machine learning \u003ealgorithms.\n\u003e   \n\u003e2. **Data Splitting:** Split the dataset into a training set and a testing set. By splitting the data, we ensure that we're not just making a model that's good on \u003epaper but one that will actually work well when it's used in real applications.\n\u003e   \n\u003e**The training set includes 8,000 samples, and the testing set includes 2,000 samples, with 14 features in each.**\n\n### 2. Model Creation using Logistic Regression\n``` Python\n# Training Logistic Regression Model\nlogistic_model = LogisticRegression(max_iter=1000, random_state=42)\nlogistic_model.fit(X_train, y_train)\n\n# Predicting on the test set\ny_pred_logistic = logistic_model.predict(X_test)\n\n# Evaluating the model\naccuracy_logistic = accuracy_score(y_test, y_pred_logistic)\nprint(\"Accuracy Score of Model on Test Data is =\u003e\", round(accuracy_logistic * 100, 2), \"%\")\n\nreport_logistic = classification_report(y_test, y_pred_logistic, output_dict=True)\n\nprint(\"F1 Score of the Model is =\u003e\", f1_score(y_test, y_pred_logistic))\nprint(\"Recall Score of the Model is =\u003e\", recall_score(y_test, y_pred_logistic))\nprint(\"Precision Score of the Model is =\u003e\", precision_score(y_test, y_pred_logistic))\n```\n\u003eLogistic Regression is a type of statistical analysis used to predict the outcome of a variable that can be one of two types; 0 (no chance)\n\u003e\u0026 1 (certain to \u003ehappen)\n\u003e\n\u003e**Result:**\n\u003e\n\u003e**Accuracy Score** of Model on Test Data is =\u003e 79.2 %\n\u003e\n\u003e**F1 Score** of the Model is =\u003e 0.0956521739130435\n\u003e\n\u003e**Recall Score** of the Model is =\u003e 0.05392156862745098\n\u003e\n\u003e**Precision Score** of the Model is =\u003e 0.4230769230769231\n\u003e\n\u003e**Insight:**\n\u003e\n\u003eThe Logistic Regression model achieved an accuracy of 79.2% on the test set. However, a closer look at the precision, recall, and F1-score reveals some important \u003edetails:\n\u003e\n\u003e1. **Precision Score** for class 1 (exited) is relatively low at 42%, indicating that the model isn't very good at identifying exited customers accurately.\n\u003e   \n\u003e2. **Recall** for class 1 is very low at 5%, meaning the model fails to identify a significant portion of the actual exited customers.\n\u003e   \n\u003e3. **F1-score** for class 1 is also quite low at 10%, which combines precision and recall, indicating poor performance on the minority class.\n\u003e   \n\u003eLogistic Regression seems to not be a best model for this data. Below is the Implication and Suggestions:\n\u003e\n\u003e1. **Class Imbalance:** One common reason for such results is class imbalance. Non-exited customer is more than exited customer. The model might be biased towards predicting the majority class (non-exited). It's worth checking the class distribution and considering techniques like SMOTE, adjusting class weights, or resampling to address imbalance.\n\u003e   \n\u003e2. **Model and Variables Reassessment:** The current variables might not be strong indicators of the outcome, or logistic regression may not be the best model for this data. We will consider exploring other models like Random Forests or Gradient Boosting Machines (GBMs), which we will learn in near future.\n\n\n### 3. Importance Variables in the Model Prediction\n``` Python\nimportance = logistic_model.coef_[0]\n\n# Matching the Variables importance with the column names of the training data\nfeatures = X_train.columns\nimportance_df = pd.DataFrame({'Variable Name': features, 'Importance': importance})\n\n# Since we want to visualize the absolute values of the importance\nimportance_df['Importance'] = np.abs(importance_df['Importance'])\n\n# Sort the Variables by importance\nimportance_df = importance_df.sort_values(by='Importance', ascending=False)\n\n# Visualizing the Importance Variables\nplt.figure(figsize=(12,7))\nsns.barplot(x=\"Importance\", y=\"Variable Name\", data=importance_df, palette=\"plasma\")\nplt.title(\"Importance Variables in the Model Prediction\", fontweight=\"black\", size=20, pad=20)\nplt.yticks(size=12)\nplt.show()\n```\n\u003e![Customer Turnover Distribution](images/Var.png)\n\u003eThe key factors that significantly influence the deactivation of customers banking facilities are:- Age, Complain, Credit Score and IsActiveMember\n\n## Conclusion:\n\u003e**Key-Points:**\n\u003e1. **Model Performance:** The logistic regression model provided a reasonable baseline performance with turnover customers, which is evident from the low recall and F1 score for the positive class.\n\u003e   \n\u003e2. **Feature Importance:** The feature importance analysis from the logistic regression model can provide insights into which factors are most influential in predicting customer turnover. Important features may include customer age, account balance, number of products, credit score, and activity level. Understanding these can help inform strategies to retain customers.\n\u003e\n\u003e3. **Business Insights:** Active membership appears to be a strong indicator of retention, suggesting that efforts to engage customers could reduce turnover. Older \u003ecustomers were more likely to turnover, highlighting a potential area to explore tailored retention strategies. The presence of a credit card did not show a \u003estrong correlation with turnover, suggesting that simply having a credit card isn't a deciding factor in customer retention.\n\u003e   \n\u003e**Strategic Recommendations:**\n\u003e\n\u003e1. Investigate the reasons behind the turnover of older customers and consider offering products or services that might be more appealing to them.\n\u003e \n\u003e2. Enhance customer engagement and satisfaction, perhaps by improving customer service or offering loyalty programs, as active members are less likely to turnover.\n\u003e \n\u003e3. Consider a more detailed analysis of the customers with high balances who exited to understand if there are specific services or products that are not meeting\n\u003e   their needs.\n\u003e   \n\n*Side Note:*\n*The goal of this analysis is not only to predict turnover but also to understand its drivers so that targeted actions can be taken to reduce it. With these insights, a business can develop focused retention strategies to maintain a healthier customer base.*\n\n## If you are interested to look on more details on each Coding, EDA \u0026 Results\n## Click here: [Bank Turnover Analysis](https://colab.research.google.com/drive/1T8MYyxysA7KzMLcFFeGgJyYvb5Yci3bA#scrollTo=lkCi_np54J5R)\n\n# \u003cdiv align=\"center\"\u003eEnjoy 👍\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazlinrusnan%2Fbank_turnover_analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazlinrusnan%2Fbank_turnover_analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazlinrusnan%2Fbank_turnover_analysis/lists"}