This tutorial will allow you to set up an automated retail customer cross-sell modeling scenario inside SQL Server.
This tutorial will allow you to set up an automated retail customer cross-sell modeling scenario inside SQL Server. The tutorial includes the SQL code, along with some sample data for you to try. I have also included the original R script used to build and test the code, which you could use from the IDE of your choice to watch this execute step-by-step and see the intermediate results. The SQL code itself calls *sp_execute_external_script* and runs R code to: - Build a series of response models; one model per product, using all other products as inputs - Takes each model and scores all customers on their probability to buy each product - Orders and reshapes the data to create the output - a Recommendations table in the DB that provides a rank-ordered listing of products to offer each customer This cross-sell modeling scenario would also apply to situations in which you are faced with a series of response models. Although the product data is provided as a series of bought/hasn’t bought (1/0) indicators, the code should also work with product quantities or dollar amounts, though the algorithm and some code may need to be modified to fit those scenarios. I have only provided one file for both modeling and scoring. Normally you would have a separate set of data for scoring. The included data can be imported into SQL Server and the code can be run inside SQL Server Management Studio. This code could easily be called externally for automation/scheduling purposes. Project data and code can be found [here]. : https://github.com/Microsoft/SQL-Server-R-Services-Samples/tree/master/ProductCrossSell