Preventing Customer Churn With Deep Learning
?? Matt Dancho ??
Sharing my journey to becoming a Generative AI Data Scientist. Join 1,000+ in my next free workshop. ??
Many organizations have a big problem that can go undiagnosed - customer churn. Actions can be taken to prevent this situation from occurring, but only if organizations can spot the problem and develop strategies to reduce it. In this article, we show how you can use Deep Learning, a specialized subset of Machine Learning algorithms that are capable of high accuracy models, to predict customer churn. The cool thing is we did this in... R. Traditionally, deep learning is performed in Python for computer image recognition and cognitive prediction. I've found that R is a more intuitive language for non-programmers, and I'm excited to show you how this new toolset is available for business analysis!
- The original article first appeared on the Business Science blog. See the article for full code and examples.
- The article also appeared on the RStudio TensorFlow blog.
- Please visit our Services for the deep learning-powered, interactive Customer Health Scorecard.
What's Customer Churn?
The problem of customer churn is often visualized as the act of filling a bucket with holes. An organization spends a lot of time, effort and money attracting customers, but if they don't fix the problems (patch the holes) they end up losing in the end. Think about it: It takes a lot of effort to get customers. Keep them!
It takes a lot of effort to get customers. Keep them!
The Problem: Customers Are Leaving!
We took a data set that the folks at IBM developed for a fictional telecommunications company, Telco. While it was artificially generated, it mimics a real-world scenario that many companies face. It contains 21 features for 7000+ customers, with features covering:
- Customers who left within the last month: The column is called Churn
- Services that each customer has signed up for: phone, multiple lines, internet, online security, online backup, device protection, tech support, and streaming TV and movies
- Customer account information: how long they’ve been a customer, contract, payment method, paperless billing, monthly charges, and total charges
- Demographic info about customers: gender, age range, and if they have partners and dependents
The Solution: Churn Modeling With Artificial Neural Networks (Keras)
Artificial Neural Networks (ANN) are now a staple within the sub-field of Machine Learning called Deep Learning. Deep learning algorithms can be vastly superior to traditional regression and classification methods (e.g. linear and logistic regression) because of the ability to model interactions between features that would otherwise go undetected. The challenge becomes explainability, which is often needed to support the business case.
Deep learning algorithms can be vastly superior to traditional methods
We used several new techniques to get the best of both worlds (high accuracy + explainability):
Deep Learning With Keras
The keras deep learning model implemented is a feed-forward neural network using two hidden layers and drop out layers in between to reduce overfitting. Here's the R code.
# Building our Artificial Neural Network
model_keras <- keras_model_sequential()
model_keras %>%
# First hidden layer
layer_dense(
units = 16,
kernel_initializer = "uniform",
activation = "relu",
input_shape = ncol(x_train_tbl)) %>%
# Dropout to prevent overfitting
layer_dropout(rate = 0.1) %>%
# Second hidden layer
layer_dense(
units = 16,
kernel_initializer = "uniform",
activation = "relu") %>%
# Dropout to prevent overfitting
layer_dropout(rate = 0.1) %>%
# Output layer
layer_dense(
units = 1,
kernel_initializer = "uniform",
activation = "sigmoid") %>%
# Compile ANN
compile(
optimizer = 'adam',
loss = 'binary_crossentropy',
metrics = c('accuracy')
)
# Fit the keras model to the training data
fit_keras <- fit(
object = model_keras,
x = as.matrix(x_train_tbl),
y = y_train_vec,batch_size = 50,
epochs = 35,validation_split = 0.30
)
We were able to visualize our training and validation performance to ensure we were getting a well fit model. Applying our model to the test set yielded accuracy in the neighborhood of 82%!
Well, That's Great! But, What Does It Mean?
We have a high accuracy model that's really good at predicting if customers are going to leave. So, what?! We want to know what we can do to change this behavior! Here's where lime comes into play. LIME helps us understand why a model predicts what it predicts. In other words, which features are the most important to whether or not the customer stays?
We ran LIME on the first 10 customers from our test data set (held out during), and here's the visualization. We can see Case 2 and Case 7 were predicted to leave while the others were predicted to stay. Case 7 was particularly likely to leave (78% probability), and it looks like Phone Service = Yes was a leading contributor.
We cross-checked the LIME results with a correlation analysis, which led us to the following features that were targeted for investigation:
- Tenure (7/10 LIME Cases, Highly Correlated)
- Contract Type (Highly Correlated)
- Internet Service (Highly Correlated)
- Payment Method (Highly Correlated)
- Senior Citizen (5/10 LIME Cases)
- Online Security (4/10 LIME Cases)
By investigating the features, we could then develop strategies! Here are a few examples.
Tenure
Opportunity: Target customers with less than 12-month tenure.
Contract Type
Opportunity: Offer promotion to switch to long-term contracts.
Internet Service
Improvement Area: Customers may be dissatisfied with fiber optic service.
Customer Scorecard: An Interactive Web App For The Front Lines!
While strategies are great for high-level decision makers in the organization, what is really needed are actionable tactics that the front-line decision makers can enact.
What is really needed are actionable tactics that the front-line decision makers can enact
Enter the Customer Health Scorecard application! We created a web application to generate actionable recommendations using the deep learning model predictions and lime analysis of features that are important. The app allows the front-lines to build data into their customer retention tactics!
Data Science For Business!
Data science can solve a number of business problems, which translates into improved customer experiences, happier employees, and ultimately better financial performance. In this article, we saw how Deep Learning can be used to predict customer churn, but this is just one of the many challenges that can be solved with data science. If you're interested in using data science for business:
- Follow Business Science - Get all the updates and news from Business Science.
- Subscribe to the Business Science Blog - This gives you FREE access to data science for business articles, now and into the future.
- Enroll in Business Science University - This goes beyond the blog articles, teaching our learners cutting-edge Machine Learning techniques and how to build interactive web applications that can be distributed throughout an organization.
- Contact Business Science for consulting services - We'll learn and understand your challenges, build ML models, and make the ML-powered web apps for you! Just contact us.
About The Author
Matt is the Founder of Business Science, a consultancy that helps organizations apply data science to drive ROI and make better decisions. Matt loves feedback. Feel free to connect with/contact him.
- Web: www.business-science.io
- Twitter: @mdancho84
- LinkedIn: mattdancho
- Email: [email protected]
Computational Linguist at Samsung
6 年This is great! Working with sales operations, having new methods to understand customer churn is important
Digital User Experience
6 年This is really nice...
Helping Aussie Retailers Streamline Operations with POS Software. Assisted 100+ Stores Boost Efficiency & Enhance Customer Experience.
7 年I am dubious about this result, we did an extensive study of customer churn in our business and found that it was related to many factors, that were not in our CRM at all, for example, a salesman walks in the door of one of our clients.
FinTech | InsurTech | Technology | Ai & Data Manager
7 年Allan Byrne
Retired Telecom Professional
7 年I believe it when I see actual results. Unlike Go or Chess, churn is not that easily learnable by algorithms.