Using Artificial Neural Network to classify Churning Customers
Artificial Neural Network: Customer Churning Model
Introduction The aim of the project to classify the Churning Customers based on various features related to the bank. In this model, I applied Artificial Neural Network using “Keras” package (working on “Tensorflow” backend) to classify the “Exited” customer. Later, I also applied XGBoost Classifier to speed up the process and compare their accuracies.
Dataset: Dataset consist of 12 features and one target variable.
Features are as follows:
- CustomerId: Customer Id, int
- Surname: string
- CreditScore: Credit Score of customer, int
- Geography: France, Spain or Germany, qualitative
- Gender: Male or Female, qualitative
- Age: Integer
- Tenure: For how long customer is associated with the bank, int
- Balance: float
- NumOfProducts: Number of products customer has such as debit card, number of policies, etc, int
- HasCrCard: Has credit card or not, 0 or 1
- IsActiveMember: Is an active member in the past 6 months, 0 or 1
- EstimatedSalary: Salary of the customer, float
Target Variable: Exited: 0 or 1
Model Building Steps;
- Importing the dataset and partitioning it into Features and Target variable.
- Converting categorial variable: Geography and Gender into dummies.
- Dropping unnecessary features such as CustomerID and Surname
- Using train test split to split the data
- Feature scaling was done using StandardScaler function.
- Build Artificial Neural Network input layer using Sequential function in Keras.
- First layer consist of 11 number of nodes same as the number of features in our model.
- Two Hidden layers were built that consist of 6 nodes each (average of input layer nodes and output layer node). Hidden layer is activated by using ‘Rectifier function’.
- Output layer consist of one node and is activated using ‘Sigmoid Function’.
- 'adam' is used as an Optimizer and Binary Crossentropy is used as loss function.
- Model was trained on taking batch of 10 observation and running it for 100 epochs.
- Finally Classification Reports and Confusion matrix was generating resulting in f1 score of 82% and accuracy of 84.6%.
- Also, I applied XGBoost Classifier on the same dataset that resulted in slightly better accuracy of 86.29%.