Customer Churn Prediction Template with SQL Server R Services
In this tutorial, we demonstrate how to develop and deploy end-to-end customer churn prediction solutions with SQL Server 2016 R Services
In this tutorial, we demonstrate how to develop and deploy end-to-end customer churn prediction solutions with [SQL Server 2016 R Services][1]
Analyzing and predicting customer churn is important in any industry where the loss of customers to competitors must be managed and prevented – banking, telecommunications, and retail to name a few. The goal of churn analysis is to identify which customers are likely to churn, and then take appropriate actions to retain such customers and keep their business.
This template get you started with churn prevention by formulating the churn problem as a binary classification problem. It uses sample retail data from two sources to build the solution:
* **Customer demographics**. Information about the users
* **Customer transactions**. Information about the users activities with the business.
This templates demonstrate how to use SQL Server stored procedures to do model development and operationalization. The **data processing** and **feature engineering** steps are implemented using pure SQL, while the **model training, evaluation, and prediction scoring** are done using SQL procedures calling R (Microsoft R Server) code, the capability provided by SQL Server R Services. These procedures can be run within SQL environment (such as SQL Server Management Studio) or called from other applications to make predictions. A Windows **PowerShell** script is provided to run the steps end-to-end.
The code and documentation can be found [here][2]. The following is the directory structure for this template:
* **[Data][3]** This contains the provided sample data.
* **[SQLR][4]** This contains the Stored SQL procedures from data processing to model deployment. It runs in SQL environment. A Powershell script is provided to invoke the modeling steps end-to-end. See Readme files in each directory for detailed instructions.
This template is the on-prem equivalent of the [template](https://gallery.cortanaanalytics.com/Collection/Predictive-Maintenance-Template-3) in Cortana Analytics gallery.
[1]: https://msdn.microsoft.com/en-us/library/mt674876.aspx
[2]: https://github.com/Microsoft/SQL-Server-R-Services-Samples/tree/master/Churn
[3]: https://github.com/Microsoft/SQL-Server-R-Services-Samples/tree/master/Churn/Data
[4]: https://github.com/Microsoft/SQL-Server-R-Services-Samples/tree/master/Churn/SQLR