Machine Learning on Bank Marketing Data

Posted on Dec 23, 2016

Introduction

Retail Banking is aΒ provision of the services by banks to an individual consumer. Such services offered include savings/transaction accounts, mortgages, personal loans, and credit/debit cards. It is a very competitive business.
One of the biggest challenges the business faces is figuring out how to identify condumers who are most likely to do business with it and target those who have suitable needs to sign up for its services. Because of that, the marketing of services plays a vital role in winning customers over.

In this study, we have implemented multiple muchine learning algorithms on a marketing data set of an European retail bank. The goal is to understand the important factors on short-term deposit account sign-ups and to develop a strategy to help banks focus on those most promising leads in order to win them over.

The Data

The data set used here is from UCI machine learning repository. ItΒ is derived from the direct marketing campaigns of a Portuguese banking institution. The marketing campaigns were based on phone calls. Often, more than one contact to the same client was required, in order to access if the product (bank term deposit) would be ('yes') or would not be('no') subscribed.

The following categories of information are included in the data set:

Consumer data: Age, sex, job and marital status, education, loan status, and so on.
Campaign activities: When and how to contact, times to contact, outcome of previous campaigns.
Social and economic environment data: Euribor 3 month rate, employment variation rate, consumer price index, and
consumer confidence index.
Outcome: Β A 'yes' for the bank if there is a term deposit subscribed, a 'no' for the other outcome.

Data Visualization and Pre-processing

The data set contains 12 categorical variables and 7 numerical variables as its features and a binary category as its response variable. The following plots show the relationships between its economic numerical variables and the distribution of the response variable.

nfeaturesΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β  responsv
The plot on response variable shows highly unbalanced distribution of its binary classes. The relationships between the economic data are non-linear. Economic data is not normally distributed. In order to fit machine learning algorithms, all the categorical variables and response variable are encoded into numerical levels.

This data set also contains missing data on one numerical feature: pdays. This feature indicates the number of days that passed by after the client was last contacted from a previous campaign- it was coded as '999' if the contact never happened. Over 90% of the records show a number missing for the pdays. In order to implement the machine learning algorthms, we need to imput the missing values of this feature in a way to maximize its prediction accuracy.

In the study, we tested the following appraches with the Logistic Regression algorithm:

  1. Leave it as it is (999)
  2. Imput as the column mean
  3. Imput as zero
  4. Remove the column from data set

Since the result shows the highest prediction accuracy on the first apprach. we will keep the data as it is in the rest of study.

The Models and Model Optimizations

In order to meet the goal set up above, we need to develop a classification model with a balanced ability of giving correct prediction on both consumer sign-ups and no sign-ups. This model is considered as suitable since it can help marketing personnel to focus on those promising leads and reduce or eliminate effort on those who are unlikely to conduct business with them. Β To develop such model, we implemented:

  1. Rebalance the train data: Oversample the minority class to overcome the unbalanced response output
  2. Β Implement multiple classification algorithms: Explore different classification algorithms to seek the best fit
  3. Redefine model evaluation criteria: Focus on model sensitivity rather than overall accuracy
  4. Implement grid search cross validation: Find optimal model parameters
  5. Develop validation curves: Keep overfitting in check
  6. Evaluate sensitivity: Compare sensitivity through Classification Reports

The Results

The algorithms used in the study consist of Logistic Regression, Radom Forest, Gradient Boosting, Support Vector Classifier and Neural Network. Without oversampling and parameter optimization, all algorithms show around 90% accuracy overall but about 20% sensitivity on fitting and prediction of custmer sign-ups. Β After rebalancing the training data and grid search cross validation, all the algorithms except the Support Vector Classifier showed improvement on balanced sensitivities and the top two improvements were from Gradient Boosting and Neural Network. The following outputs are then generated from Logistic Regression, Gradient Boosting and Neural Network. Here Logistic Regression Β is served as a baseline other algorithm to be compared with.

Logistic Regression: Β baseline Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β Gradient Boosting: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Neural Network:
On train set: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β On train set: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β On train set:
Β  Β  Β  Β  Β  precision recall f1-score Β support Β  Β  Β  Β  Β  Β  Β precision recall f1-score Β support Β  Β  Β  Β  Β  precision recall f1-score Β support
Β class 0 Β  Β  Β 0.91 Β 0.99 Β  Β  Β  0.95 Β  Β  29229 Β  Β  class 0 Β  Β  Β 0.95 Β 0.83 Β  Β  Β  0.89 Β  Β 29229 Β  Β  class 0 Β  0.96 Β  0.44 Β  Β  Β 0.60 Β  Β  29229Β 
Β class 1 Β  Β  Β 0.67 Β 0.24Β  Β  Β  Β 0.35 Β  Β  Β  3721 Β  Β  class 1 Β  Β  Β 0.34 Β 0.67Β  Β  Β  Β 0.45 Β  Β  Β  3721 Β  Β  class 1 Β  0.16 Β Β 0.84Β  Β  Β  0.27 Β  Β  Β  3721 Β 
avg/total Β  0.88 Β  0.90 Β  Β  Β 0.88 Β  Β  32950 Β  Β avg/total Β  Β 0.88 Β 0.82 Β  Β  Β  0.84 Β  Β 32950 Β avg/total Β  0.87 Β  0.49 Β  Β  Β 0.57 Β  Β  32950 Β  Β  Β 

On test set: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  On test set: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β On test set: Β 
Β  Β  Β  Β  Β  Β precision recall f1-score Β support Β  Β  Β  Β  Β  Β  precision recall f1-score Β support Β  Β  Β  Β  Β  precision recall f1-score Β support
Β class 0 Β  Β  Β 0.91 Β  0.99 Β  Β  Β  0.95 Β  Β  Β  Β 7319 Β  Β  class 0 Β  Β 0.95 Β  Β 0.84 Β  Β  0.89 Β  Β  Β  7319 Β  Β  class 0 Β  0.96 Β  Β 0.43 Β  Β  Β  0.60 Β  Β  Β  7319
Β class 1 Β  Β  Β 0.66 Β  0.23Β  Β  Β  Β 0.35 Β  Β  Β  Β  919 Β  Β  Β class 1 Β  Β 0.34 Β  Β 0.66Β  Β  Β 0.45 Β  Β  Β  Β  919 Β  Β Β class 1 Β  Β 0.16 Β  Β 0.84Β  Β  Β  Β 0.26 Β  Β  Β  Β  919
avg/total Β  Β 0.88 Β  0.90 Β  Β  Β  0.88 Β  Β  Β  8238 Β  avg/total Β  0.88 Β  Β 0.82 Β  Β  0.84 Β  Β  Β  8238 Β avg/total Β  0.87 Β  Β 0.48 Β  Β  Β  0.56 Β  Β  Β  8238

The highlighted data shows that the sensitivity of sign-ups on fitting the train data has been increased from 24% on baseline to 67% on Gradient Boosting, and to 84% on Neural Network Classifier and that the coressponding improvements on the test set have raised from 23% to 66% and then further to 84%. By improving the sensitivity on class 1, we improve the ability of these models to predict customer sign-ups. However, sensitivity on class 0 has been reduced from 99% on baseline to 83% on Gradient Boosting, and to 44% on Neural Network on train data and from 99% to 84% and then further to 43% on test set. The reduction of sensitivity on class 0 will reduce the ability to predict no sign-ups correctly.

Further, Β let's take a look at the prediction distributions on test set:
Baseline: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Gradient Boosting: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Neural Network:
lrfinalΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β gbfinalΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  nwfinal
Compared with those true values, the prediction output on test set shows:
1. The baseline model is accrurate in making predictions in general: It is able to predict correctly over 90% of the time. However, it can only predict customer sign-up correctly 23% of the time. So the model is not informative enough to our project goal.
2. Gradient Boosting has been improved on predicting customer sign-ups correctly to 66% of the time and it is able to filter out those who will not sign-up 84% of the time.
3. Neural Network has been improved further on predicting sign-ups correctly to 84% of the time, however, its ability of filtering out those who will not sign-up was reduced to 43% of the time.
4. Β Compared with Gradient Boosting, Β Neural Network prediction is more expensive because of its failure to identify those who will not sign up.

Finally, as shown below, both Random Forest and Gradient Boosting are able to identify those features which have important impacts on the response variable. These outputs supply very valuable insight to guide further marketing campaign.
From Random Forest: Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  From Gradient Boosting:
featureimportancerfΒ  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β Β featureimportancegbt
The differences of feature importances reflect the differences of mechanism between thees models.

Conclusion

In this study, we have applied machine learning techniques to retail bank marketing data and explored how the techniques can be used to help Β the bank to conduct its marketing campaign:

  1. Multiple Classification Algorithms have been evaluated.
  2. Oversampling/undersampling has been implemented for unbalanced data.
  3. Cross Validation was used for parameter selection.
  4. Gradient Boosting is the best model for balanced sensitivities and interpretation of feature importance.
  5. Neural Network has the best ability to predict sign-ups but gives no insight on feature influence.
  6. Both Gradient Boosting and Neural Network can add value to further a marketing campaign.

 

 

About Author

Connie Zhang

Connie Zhang, a marketing specialist, has been working in the field of data analysis since 2010. She holds a Ph.D. in Engineering,MBA and an Associateship of the Society of Actuary in United States.
View all posts by Connie Zhang >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI