Customer churn prediction on Financial Dataset using Artificial Neural Network
Based on past data of how a customer is doing his/her transactions we analyze whether the customer will stay with our bank’s plans or move to some other service provider. This is done by first cleaning dataset, visualizations of how data is related and then train test split to help train the model. This model helps us tell with new inputs whether the customer would stay or leave the current provider.
This is a classification task wherein we predict if the customer will stay with us or move to some other organization to use their services. To achieve this, we train the Artificial Neural Network(ANN) on the training dataset, perform required transformations and go with training. At the end of 10 epochs (going through training data 10 times). Each could be termed like a revision, the number of times our model will go through the whole training data for training and adjusting the weights to get the best possible accuracy. We get 81% accuracy on the dataset which is okay.
The dataset contains 21 columns like gender of customer, tenure of the stay of customer with bank etc and the target column is “Churn”. All these parameters will help us to train the model to understand the relation of all columns with the target column i.e “Churn” as to why customers are leaving our services.
ANN is a neural network which tries to perform tasks like a human does, think like a human brain. Just like a human brain understands things after learning by watching things or by experience, ANN does the same as well. It learns with experience of going through the dataset multiple times and understands the relations, hidden features and parameters. ANN is helpful in doing regression, classification tasks and performs extremely well on huge datasets achieving high accuracy.
Whatever input you pass for the model to learn goes through this layer of neural network for performing calculations.
The layer as the name suggests hidden because when we see the real time application we only focus on the input and output, we do not focus on how things happen. Hidden layer performs calculations, does processing, understands the hidden features and updates weights to get the best possible accuracy.
The input passes through hidden layer where processing happens and output is returned.
For detailed explanation of ANN, refer to this blog https://ai.plainenglish.io/artificial-neural-network-ann-edec89ce4daa .
How to Execute?
So, before execution we have some pre-requisites that we need to download or install i.e., anaconda environment, python and a code editor.
Anaconda: Anaconda is like a package of libraries and offers a great deal of information which allows a data engineer to create multiple environments and install required libraries easy and neat.
If you are just starting and want to know how to install anaconda refer to this link
If you already have anaconda and want to check on how to create anaconda environment, set up jupyter notebook refer to this article. You can skip the article if you have knowledge of installing anaconda, setting up environment and installing requirements.txt
1. Install necessary libraries from requirements.txt file provided.
2. Go to the directory, Type cd and paste the path of the directories where the requirement.txt file is present.
E.g. cd D:\bhavani drive\P\deep-learning-keras-tf-tutorial-master\11_chrun_prediction\customer_churn
3. Run command pip install -r requirements.txt or conda install requirements.txt (Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually.)
All the required files will be downloaded after you run it. I got requirement already satisfied as I already have them installed.
To run the code, start jupyter notebook
When you run the BankTurnoverPrediction.ipynb file, you get the appropriate results.
We go through the dataset, do visualizations to help us understand the data, how they are organized, related to each other.
Code to create our neural network and train model on data
Accuracy of 78% for the dataset
Issues you may face while executing the code
1. Make sure to change the path in the code. Give full path of dataset/csv file you want to use.
2. Make sure you have the appropriate versions of tensorflow and keras.