Predicting Churn for Bank’s Customer using ANN

Photo by Vic López on Dribbble

Churn is a process where an individual stops doing his work/business with an particular entity. Churning or Attrition can happen anywhere such as Employee churn, customer churn etc. This process is quite tedious to understand , as there is no fixed pattern or formula to calculate .

Bank Customer Churn: Its a type of churning where the entity loses its customer’s or clients. Due to which ,banks suffers from huge losses or even can go bankrupt. So to avoid such things ,banks should take necessary precautions.

In this blog, we are going to explain how deep learning can be useful to track down customers based upon certain parameters such as age, balance ,location, no of credit cards etc.

Table of Contents:

→Dataset

→Data Visualization

→Data Preprocessing (Feature Scaling And Encoders)

→Model Evaluation

→Graph Plotting

→Model Prediction

DataSet:

The dataset is available on Kaggle which was given by Adam.

https://www.kaggle.com/adammaus/predicting-churn-for-bank-customersAdam

The dataset contains 14 rows and 10000 rows ,and has both categorical as well as numerical data.

Data Visualization:

Basically, data visualisation gives us a clear picture of what the data means by putting it in context via maps, graphs, and heatmaps. This makes the data easier to interpret for the human mind, making it easier to see trends, patterns, and outliers within data sets.

There are various tool for visualization such as

>Matplotlib

>Plotly

>Seaborn

>GGplot

>Bokeh

Here we will be using Seaborn,which is an excellent tool when it comes to draw heat maps.

Heatmap

Feature Scaling:

Its one of the most important preprocessing step for many ML/DL models. Its work is to normalize the given range of features or independent variables.

There are various methods available for scaling the features ,but the most 2 comman methods are Normalization and Standardization.

In this model, we have used Standard Scaler which removes the mean and scale to unit variance to standardize characteristics.

https://gist.github.com/tanmay1070/fc2c1f4f0f72605551cf5f8177150794

One Hot Encoder V/s Label Encoder

We have used Label Encoder for “gender” column and One hot encoder for “geography” column.

The reason for using label encoder was ,there were 2 entity such such as Male and Female ,so we just needed to convert the existing data with new data.

https://gist.github.com/tanmay1070/4a4ce4d204cb742fc2e99fb36ebce982

The reason for using one hot encoder was, there were 3 countries mentioned in the dataset. Now for eg,if we gave 0 to France ,1 to Germany then the 3rd country ie Spain will not be assigned anything.

So using one hot encoder will be useful as it does the work as mentioned below:

0/1 0/10/1

France 1 0 0

Spain 0 1 0

Germany 0 0 1

https://gist.github.com/tanmay1070/9e24f794443e284ce3b5913ecec8329c

Model Training:

We have using ANN for training the model,

epoch_size=25

optimizer=adam

https://gist.github.com/tanmay1070/bf331e8361e694d68ff6c6b2c0c39ef9

Graph Plotting:

Train VS Validation(Loss)
Train VS Validation (Accuracy)

Model Prediction:

The model was able to yield an accuracy of 86.40%.

The model returns 2 values:

False : If the customer will not will the bank, then the model will return this value.

True: If the customer will leave the bank, then the model will return this value.

eg.

https://gist.github.com/tanmay1070/8cbb8d78ec18e3d250fb3e7f37749448https://gist.github.com/tanmay1070/13310722e9d8f9b30f539e94e9431dae

Link :

Click the below link to access the Notebook .

https://cainvas.ai-tech.systems/use-cases/predicting-churn-for-bank-customers-app/

Credit: Tanmay