Skip to content

End to End Azure solution architecture to prevent customer's churn

License

Notifications You must be signed in to change notification settings

MediaEntertainmentLabs/Churn-Retention-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

Managing Retention and Churn with Azure and Databricks

End to End solution built with Azure Databricks and other Azure services (Synapse, Azure Function, Logic App, Power BI) to predict churns and so retain customers.
The KKbox datasets used are from Kaggle challenge: https://www.kaggle.com/c/kkbox-churn-prediction-challenge/data.
KKbox is a music streaming service.
Machine Learning models are from the Databricks blog: https://databricks.com/blog/2020/08/24/profit-driven-retention-management-with-machine-learning.html

Overview

image


Data have been manually copied to Azure Data Lake from Kaggle.
In a real scenario, data will be sourced from transactional systems.

image

Results

Use a Power BI dashboard to get meaningfull insights and prevent customers to churn
image

Prerequisites

Deployment

Run the following commands from the automatic deployment directory (run them from a powershell):

  • terraform init
  • terraform plan
  • terraform apply -auto-approve

Deployment will create all the resources part of the architecture.
image In addition of creating resources, deployment will also:

  • Azure Databricks
    • Upload notebooks in the Databricks Workspace
  • Azure Synapse Analytics
    • Upload Sql scripts in Azure Synapse Analytics
    • Create the Linked Services
    • Create the Datasets
    • Create the Pipelines
  • Azure Data Lake Storage
    • Create the directories where raw data and predictions will be saved

From the resource-group tf file in the resource-group directory, you will find out what is the name of the resource group created. Per default, resource group name will start with e2e-churn-demo-

Step 1 Databricks setup

Step 2 Role assignment

https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal?tabs=current

Step 3 Run the sql scripts in the Synapse Serverless Pool

When deploying the solution, SQL scripts are uploaded automatically.
image

Please run at least these 2 scripts in this order on the serverless pool:
https://docs.microsoft.com/en-us/azure/synapse-analytics/sql/author-sql-script#run-your-sql-script

  • Create Database Demo
  • Create Master Key
    • choose a Master Key Encryption password and run the script using the Database Demo
  • Run any SQL script left


Make sure to select the serverless Pool image

Step 4 Check Linked Services in Azure Synapse

When deploying the solution, Linked Services are created automatically.

Please verify the connection for the following Linked Services:

Step 5 Azure Function (optional)

An Azure function is automatically created once deployment is complete.
You will have to implement the code. In this case, bind the function to a queue.
In this architecture we are sending a message to a queue (predictionChurning) to trigger a logic app workflow. The logic app will send an email with a Power BI dashboard attached containing information about potential customer churns.
image
image
image https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook

Step 6 Azure Logic App (optional)

You can implement easily different type of logic with logic app.
In this architecture, we use it to automatically refresh the Power BI report then send an email with the dashboard attached.
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-overview
You might need either Power BI premium or enable Power BI embedded to make the Power Bi part working


image

Step 7 Run the different pipelines

  • You can create the model directly in Databricks or use the pipeline Churning Model Creation in Azure Synapse
    • You will have to mount the storage and have the KKbox dataset in your datalake.
  • You can run the prediction notebook in Databricks or use the pipeline Churning predictions in Azure Synapse
  • You can run the notification pipeline in Azure Synapse to trigger the Logic app workflow and receive the Power BI report automatically in an email.

Resources

About

End to End Azure solution architecture to prevent customer's churn

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages