Retail customer analytics with SQL Server R Services

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In the hyper-competitive retail industry, intelligence about your customers is key. You need to be able to find the right customers, understand what types of customers you have, and know how to keep the best ones. Three solutions based around R and SQL Server R Services will help you do exactly that. 

To find the right customers, you need to optimize your marketing activites. You might use different channels (phone, email, social media etc.) to try and reach potential customers, and some offers are likely to resonate more with certain prospects than others. Results from prior campaigns can be used to learn which channels and offers are the most effective, and to select the best offer using the best channel for future prospects. The Marketing Campaign Optimization Solution provides a template that uses SQL Server R Services to apply a predictive model to simulated data. After the one-click deploy process (which launches an Azure VM for you), you can adapt the template to use your own data to create an interactive PowerBI dashboard for campaign recommendations, as shown below. Read more about the solution in this blog post.

Campaign optimization

To understand the kinds of customers you have, statistical clustering techniques are useful. The tutorial Customer Clustering with SQL Server R Services provides a step-by-step guide to applying K-means clustering techniques in the R language to customer data. The provided sample data includes purchasing and return data for a retail store, which is then used to group the customers into inactive customers, cutomers making large purchases, and customers making a large number of returns. You can then use this clustering to classify new customers as they enter the system by deploying the model to SQL Server. All of the R code behind the analysis is available in Github.


Finally, to understand which customers are most loyal (and conversely, those that are about to no longer be customers), you need to understand customer churn. The tutorial Customer Churn Prediction Template with SQL Server R Services demonstrates how to develop and deploy a model to predict which customers are likely to churn (switch to a competitor) using SQL Server and R. This template includes sample data on customer demographics and their recent transactions, while a generalized linear model is used to predict those customers most likely to churn. The R code behind this analysis is also available on GitHub.

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)